Use net.JoinHostPort to avoid IPV6 issues

This commit is contained in:
Manuel Alejandro de Brito Fontes 2020-09-02 22:01:13 -04:00
parent 2217dcf7f1
commit 8abe794178
4 changed files with 8 additions and 4 deletions

View file

@ -927,7 +927,8 @@ func updateStreamConfiguration(TCPEndpoints []ingress.L4Service, UDPEndpoints []
return err
}
conn, err := net.Dial("tcp", fmt.Sprintf("127.0.0.1:%v", nginx.StreamPort))
hostPort := net.JoinHostPort("127.0.0.1", fmt.Sprintf("%v", nginx.StreamPort))
conn, err := net.Dial("tcp", hostPort)
if err != nil {
return err
}

View file

@ -79,7 +79,8 @@ func (p *TCPProxy) Handle(conn net.Conn) {
return
}
clientConn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", proxy.IP, proxy.Port))
hostPort := net.JoinHostPort(proxy.IP, fmt.Sprintf("%v", proxy.Port))
clientConn, err := net.Dial("tcp", hostPort)
if err != nil {
return
}