Merge pull request #1198 from narqo/tunel-addr-join-host-port

Respect IPv6 when building proxy address
This commit is contained in:
Erik Wilson 2019-12-19 15:20:12 -07:00 committed by GitHub
commit 5c37454762
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"net" "net"
"reflect" "reflect"
"strconv"
"sync" "sync"
"time" "time"
@ -37,14 +38,13 @@ func getAddresses(endpoint *v1.Endpoints) []string {
for _, subset := range endpoint.Subsets { for _, subset := range endpoint.Subsets {
var port string var port string
if len(subset.Ports) > 0 { if len(subset.Ports) > 0 {
port = fmt.Sprint(subset.Ports[0].Port) port = strconv.Itoa(int(subset.Ports[0].Port))
}
if port == "" {
port = "443"
} }
for _, address := range subset.Addresses { for _, address := range subset.Addresses {
serverAddress := address.IP serverAddresses = append(serverAddresses, net.JoinHostPort(address.IP, port))
if port != "" {
serverAddress += ":" + port
}
serverAddresses = append(serverAddresses, serverAddress)
} }
} }
return serverAddresses return serverAddresses