From 8b5deac92b339b621b5a6b6219180003d1c38196 Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 30 Sep 2020 11:56:49 -0500 Subject: [PATCH 1/2] Fix 80 getting dropped from bind-addr --- src/node/cli.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/node/cli.ts b/src/node/cli.ts index e5d06955..d3afe203 100644 --- a/src/node/cli.ts +++ b/src/node/cli.ts @@ -401,7 +401,10 @@ export async function readConfigFile(configPath?: string): Promise { function parseBindAddr(bindAddr: string): [string, number] { const u = new URL(`http://${bindAddr}`) - return [u.hostname, parseInt(u.port, 10)] + // With the http scheme 80 will be dropped so assume it's 80 if missing. This + // means --bind-addr without a port will default to 80 as well and not + // the code-server default. + return [u.hostname, u.port ? parseInt(u.port, 10) : 80] } interface Addr { From 11eaf0b470c922693851c8a613e2cc2eb2fa6503 Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 30 Sep 2020 12:02:31 -0500 Subject: [PATCH 2/2] Fix being unable to use [::] for the host Fixes #1582. --- src/node/http.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/node/http.ts b/src/node/http.ts index a8abb94b..297dda0c 100644 --- a/src/node/http.ts +++ b/src/node/http.ts @@ -584,8 +584,11 @@ export class HttpServer { const onListen = (): void => resolve(this.address()) if (this.options.socket) { this.server.listen(this.options.socket, onListen) + } else if (this.options.host) { + // [] is the correct format when using :: but Node errors with them. + this.server.listen(this.options.port, this.options.host.replace(/^\[|\]$/g, ""), onListen) } else { - this.server.listen(this.options.port, this.options.host, onListen) + this.server.listen(this.options.port, onListen) } }) }