Deprecate --host and --port in favour of --bind-addr

This commit is contained in:
Anmol Sethi
2020-04-27 09:22:52 -04:00
parent f21ba53609
commit af28885ea6
5 changed files with 23 additions and 6 deletions

View File

@ -35,13 +35,21 @@ const main = async (args: Args): Promise<void> => {
const auth = args.auth || AuthType.Password
const originalPassword = auth === AuthType.Password && (process.env.PASSWORD || (await generatePassword()))
let host = args.host
let port = args.port
if (args["bind-addr"] !== undefined) {
const u = new URL(`http://${args["bind-addr"]}`)
host = u.hostname
port = parseInt(u.port, 10)
}
// Spawn the main HTTP server.
const options: HttpServerOptions = {
auth,
commit,
host: args.host || (args.auth === AuthType.Password && typeof args.cert !== "undefined" ? "0.0.0.0" : "localhost"),
host: host || (args.auth === AuthType.Password && args.cert !== undefined ? "0.0.0.0" : "localhost"),
password: originalPassword ? hash(originalPassword) : undefined,
port: typeof args.port !== "undefined" ? args.port : process.env.PORT ? parseInt(process.env.PORT, 10) : 8080,
port: port !== undefined ? port : process.env.PORT ? parseInt(process.env.PORT, 10) : 8080,
proxyDomains: args["proxy-domain"],
socket: args.socket,
...(args.cert && !args.cert.value