Join host/port with go helper (supports ipv6)
This commit is contained in:
parent
0a9db37e0f
commit
361f06b791
2 changed files with 4 additions and 2 deletions
|
@ -20,6 +20,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
|
@ -100,7 +101,7 @@ func getEndpoints(s *corev1.Service, port *corev1.ServicePort, proto corev1.Prot
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, epAddress := range ss.Addresses {
|
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 {
|
if _, exists := processedUpstreamServers[ep]; exists {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
|
@ -66,7 +67,7 @@ var _ = framework.IngressNginxDescribe("Proxy Protocol", func() {
|
||||||
port, err := f.GetNginxPort("http")
|
port, err := f.GetNginxPort("http")
|
||||||
Expect(err).NotTo(HaveOccurred())
|
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())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue