Merge pull request #531 from joscha-alisch/dont-allow-same-port-twice
Try to open port before allowing itmine
commit
07e67c7e98
|
|
@ -3,6 +3,7 @@ package view
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/derailed/k9s/internal/client"
|
"github.com/derailed/k9s/internal/client"
|
||||||
|
|
@ -140,3 +141,11 @@ func (c *Container) isForwardable(path string) ([]string, bool) {
|
||||||
|
|
||||||
return pp, true
|
return pp, true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func tryListenPort(port string) error {
|
||||||
|
server, err := net.Listen("tcp", fmt.Sprintf(":%s", port))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return server.Close()
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue