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 (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/derailed/k9s/internal/client"
|
||||
|
|
@ -140,3 +141,11 @@ func (c *Container) isForwardable(path string) ([]string, bool) {
|
|||
|
||||
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