Skip to content

Commit

Permalink
Join host/port with go helper (supports ipv6)
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Sep 9, 2018
1 parent 0a9db37 commit 361f06b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion internal/ingress/controller/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"net"
"reflect"
"strconv"

"github.com/golang/glog"

Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/settings/proxy_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"io/ioutil"
"net"
"strconv"
"strings"

. "github.com/onsi/ginkgo"
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 361f06b

Please sign in to comment.