@@ -414,9 +414,9 @@ export async function setDefaults(cliArgs: Args, configArgs?: ConfigArgs): Promi
414
414
args . auth = AuthType . Password
415
415
}
416
416
417
- const [ host , port ] = bindAddrFromAllSources ( args , configArgs || { _ : [ ] } )
418
- args . host = host
419
- args . port = port
417
+ const addr = bindAddrFromAllSources ( args , configArgs || { _ : [ ] } )
418
+ args . host = addr . host
419
+ args . port = addr . port
420
420
421
421
// If we're being exposed to the cloud, we listen on a random address and
422
422
// disable auth.
@@ -512,12 +512,15 @@ export async function readConfigFile(configPath?: string): Promise<ConfigArgs> {
512
512
}
513
513
}
514
514
515
- function parseBindAddr ( bindAddr : string ) : [ string , number ] {
515
+ function parseBindAddr ( bindAddr : string ) : Addr {
516
516
const u = new URL ( `http://${ bindAddr } ` )
517
- // With the http scheme 80 will be dropped so assume it's 80 if missing. This
518
- // means --bind-addr <addr> without a port will default to 80 as well and not
519
- // the code-server default.
520
- return [ u . hostname , u . port ? parseInt ( u . port , 10 ) : 80 ]
517
+ return {
518
+ host : u . hostname ,
519
+ // With the http scheme 80 will be dropped so assume it's 80 if missing.
520
+ // This means --bind-addr <addr> without a port will default to 80 as well
521
+ // and not the code-server default.
522
+ port : u . port ? parseInt ( u . port , 10 ) : 80 ,
523
+ }
521
524
}
522
525
523
526
interface Addr {
@@ -528,7 +531,7 @@ interface Addr {
528
531
function bindAddrFromArgs ( addr : Addr , args : Args ) : Addr {
529
532
addr = { ...addr }
530
533
if ( args [ "bind-addr" ] ) {
531
- ; [ addr . host , addr . port ] = parseBindAddr ( args [ "bind-addr" ] )
534
+ addr = parseBindAddr ( args [ "bind-addr" ] )
532
535
}
533
536
if ( args . host ) {
534
537
addr . host = args . host
@@ -543,16 +546,17 @@ function bindAddrFromArgs(addr: Addr, args: Args): Addr {
543
546
return addr
544
547
}
545
548
546
- function bindAddrFromAllSources ( cliArgs : Args , configArgs : Args ) : [ string , number ] {
549
+ function bindAddrFromAllSources ( ... argsConfig : Args [ ] ) : Addr {
547
550
let addr : Addr = {
548
551
host : "localhost" ,
549
552
port : 8080 ,
550
553
}
551
554
552
- addr = bindAddrFromArgs ( addr , configArgs )
553
- addr = bindAddrFromArgs ( addr , cliArgs )
555
+ for ( const args of argsConfig ) {
556
+ addr = bindAddrFromArgs ( addr , args )
557
+ }
554
558
555
- return [ addr . host , addr . port ]
559
+ return addr
556
560
}
557
561
558
562
async function copyOldMacOSDataDir ( ) : Promise < void > {
0 commit comments