Use address:port tuple when checking port forwarding

Every address has it's own set of ports. We need to take the address
we're binding to into account when checking we can open the port.
mine
Simon Jones 2020-02-27 09:33:04 +00:00
parent e936b17fd0
commit 9bb9f677fa
1 changed files with 3 additions and 3 deletions

View File

@ -72,8 +72,8 @@ func (p *PortForwardExtender) fetchPodName(path string) (string, error) {
// ----------------------------------------------------------------------------
// Helpers...
func tryListenPort(port string) error {
server, err := net.Listen("tcp", fmt.Sprintf(":%s", port))
func tryListenPort(address, port string) error {
server, err := net.Listen("tcp", fmt.Sprintf("%s:%s", address, port))
if err != nil {
return err
}
@ -101,7 +101,7 @@ func runForward(v ResourceViewer, pf watch.Forwarder, f *portforward.PortForward
}
func startFwdCB(v ResourceViewer, path, co string, t client.PortTunnel) {
err := tryListenPort(t.LocalPort)
err := tryListenPort(t.Address, t.LocalPort)
if err != nil {
v.App().Flash().Err(err)
return