Merge pull request #4521 from cli/jg/bind-locally
codespace: switches port binding to 127.0.0.1 where possible
This commit is contained in:
commit
b0360612d2
3 changed files with 5 additions and 3 deletions
|
|
@ -52,7 +52,7 @@ func PollPostCreateStates(ctx context.Context, logger logger, apiClient apiClien
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Ensure local port is listening before client (getPostCreateOutput) connects.
|
// Ensure local port is listening before client (getPostCreateOutput) connects.
|
||||||
listen, err := net.Listen("tcp", ":0") // arbitrary port
|
listen, err := net.Listen("tcp", "127.0.0.1:0") // arbitrary port
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ func (a *App) Logs(ctx context.Context, codespaceName string, follow bool) (err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure local port is listening before client (getPostCreateOutput) connects.
|
// Ensure local port is listening before client (getPostCreateOutput) connects.
|
||||||
listen, err := net.Listen("tcp", ":0") // arbitrary port
|
listen, err := net.Listen("tcp", "127.0.0.1:0") // arbitrary port
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,9 @@ func (a *App) SSH(ctx context.Context, sshArgs []string, opts sshOptions) (err e
|
||||||
usingCustomPort := localSSHServerPort != 0 // suppress log of command line in Shell
|
usingCustomPort := localSSHServerPort != 0 // suppress log of command line in Shell
|
||||||
|
|
||||||
// Ensure local port is listening before client (Shell) connects.
|
// Ensure local port is listening before client (Shell) connects.
|
||||||
listen, err := net.Listen("tcp", fmt.Sprintf(":%d", localSSHServerPort))
|
// Unless the user specifies a server port, localSSHServerPort is 0
|
||||||
|
// and thus the client will pick a random port.
|
||||||
|
listen, err := net.Listen("tcp", fmt.Sprintf("127.0.0.1:%d", localSSHServerPort))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue