mirror of
https://github.com/danog/code-server.git
synced 2024-11-27 04:45:52 +01:00
Merge pull request #2146 from cdr/listen
This commit is contained in:
commit
548a35c0ee
@ -401,7 +401,10 @@ export async function readConfigFile(configPath?: string): Promise<Args> {
|
|||||||
|
|
||||||
function parseBindAddr(bindAddr: string): [string, number] {
|
function parseBindAddr(bindAddr: string): [string, number] {
|
||||||
const u = new URL(`http://${bindAddr}`)
|
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 <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 {
|
interface Addr {
|
||||||
|
@ -584,8 +584,11 @@ export class HttpServer {
|
|||||||
const onListen = (): void => resolve(this.address())
|
const onListen = (): void => resolve(this.address())
|
||||||
if (this.options.socket) {
|
if (this.options.socket) {
|
||||||
this.server.listen(this.options.socket, onListen)
|
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 {
|
} else {
|
||||||
this.server.listen(this.options.port, this.options.host, onListen)
|
this.server.listen(this.options.port, onListen)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user