From 9bb9f677fa36d90b3f033f01bae5f34b655ca5a4 Mon Sep 17 00:00:00 2001 From: Simon Jones Date: Thu, 27 Feb 2020 09:33:04 +0000 Subject: [PATCH] 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. --- internal/view/pf_extender.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/view/pf_extender.go b/internal/view/pf_extender.go index 1b61d988..ac110d56 100644 --- a/internal/view/pf_extender.go +++ b/internal/view/pf_extender.go @@ -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