-
Notifications
You must be signed in to change notification settings - Fork 752
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: adding 'listen' option to restrict binding of interfaces
- Loading branch information
1 parent
ef12e9a
commit d641916
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import {BsTempOptions, TransformResult} from "../cli-options"; | ||
import {BsErrorLevels, BsErrorTypes} from "../../bin"; | ||
|
||
export function handleHostOption(incoming: BsTempOptions): TransformResult { | ||
const host: string|null = incoming.get("host"); | ||
const listen: string|null = incoming.get("listen"); | ||
|
||
if (host && listen) { | ||
if (host !== listen) { | ||
return [incoming, [{ | ||
errors: [ | ||
{ | ||
error: new Error("Cannot specify both `host` and `listen` options"), | ||
meta() { | ||
return [ | ||
"", | ||
"Tip: Use just the `listen` option *only* if you want to bind only to a particular host.", | ||
] | ||
} | ||
} | ||
], | ||
level: BsErrorLevels.Fatal, | ||
type: BsErrorTypes.HostAndListenIncompatible | ||
}]]; | ||
} | ||
|
||
// whenever we have have both `host` + `listen` options, | ||
// we remove the 'host' to prevent complication further down the line | ||
return [ | ||
incoming.delete('host'), | ||
[]]; | ||
} | ||
|
||
return [incoming, []]; | ||
} |