From 361f06b791bfaf7f865ae57d0f5758f3890f5454 Mon Sep 17 00:00:00 2001 From: Manuel de Brito Fontes Date: Sun, 9 Sep 2018 16:34:18 -0300 Subject: [PATCH] Join host/port with go helper (supports ipv6) --- internal/ingress/controller/endpoints.go | 3 ++- test/e2e/settings/proxy_protocol.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/ingress/controller/endpoints.go b/internal/ingress/controller/endpoints.go index 368ba2b1d3..3f558638df 100644 --- a/internal/ingress/controller/endpoints.go +++ b/internal/ingress/controller/endpoints.go @@ -20,6 +20,7 @@ import ( "fmt" "net" "reflect" + "strconv" "github.com/golang/glog" @@ -100,7 +101,7 @@ func getEndpoints(s *corev1.Service, port *corev1.ServicePort, proto corev1.Prot } for _, epAddress := range ss.Addresses { - ep := fmt.Sprintf("%v:%v", epAddress.IP, targetPort) + ep := net.JoinHostPort(epAddress.IP, strconv.Itoa(int(targetPort))) if _, exists := processedUpstreamServers[ep]; exists { continue } diff --git a/test/e2e/settings/proxy_protocol.go b/test/e2e/settings/proxy_protocol.go index 95e3ebc928..acf10d7184 100644 --- a/test/e2e/settings/proxy_protocol.go +++ b/test/e2e/settings/proxy_protocol.go @@ -20,6 +20,7 @@ import ( "fmt" "io/ioutil" "net" + "strconv" "strings" . "github.com/onsi/ginkgo" @@ -66,7 +67,7 @@ var _ = framework.IngressNginxDescribe("Proxy Protocol", func() { port, err := f.GetNginxPort("http") Expect(err).NotTo(HaveOccurred()) - conn, err := net.Dial("tcp", fmt.Sprintf("%v:%v", ip, port)) + conn, err := net.Dial("tcp", net.JoinHostPort(ip, strconv.Itoa(port))) Expect(err).NotTo(HaveOccurred()) defer conn.Close()