mirror of https://github.com/k3s-io/k3s
pkg/agent/tunnel: respect ipv6 when building proxy addresses
parent
ab273a7f1c
commit
0c5299c951
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue