Commit c366ee06 authored by Roberto Bonafiglia's avatar Roberto Bonafiglia Committed by Roberto Bonafiglia

Fix comments and add check in case of IPv6 only node

parent b5f23442
...@@ -38,7 +38,7 @@ func getIPFromInterface(ifaceName string) (string, error) { ...@@ -38,7 +38,7 @@ func getIPFromInterface(ifaceName string) (string, error) {
if err != nil { if err != nil {
return "", errors.Wrapf(err, "unable to parse CIDR for interface %s", iface.Name) return "", errors.Wrapf(err, "unable to parse CIDR for interface %s", iface.Name)
} }
// skipping if not ipv4 // if not IPv4 adding it on IPv6 list
if ip.To4() == nil { if ip.To4() == nil {
if ip.IsGlobalUnicast() { if ip.IsGlobalUnicast() {
globalUnicastsIPv6 = append(globalUnicastsIPv6, ip.String()) globalUnicastsIPv6 = append(globalUnicastsIPv6, ip.String())
......
...@@ -142,10 +142,13 @@ func GetHostnameAndIPs(name string, nodeIPs cli.StringSlice) (string, []net.IP, ...@@ -142,10 +142,13 @@ func GetHostnameAndIPs(name string, nodeIPs cli.StringSlice) (string, []net.IP,
return "", nil, err return "", nil, err
} }
ips = append(ips, hostIP) ips = append(ips, hostIP)
// If IPv6 it's an IPv6 only node
if hostIP.To4() != nil {
hostIPv6, err := apinet.ResolveBindAddress(net.IPv6loopback) hostIPv6, err := apinet.ResolveBindAddress(net.IPv6loopback)
if err == nil && !hostIPv6.Equal(hostIP) { if err == nil && !hostIPv6.Equal(hostIP) {
ips = append(ips, hostIPv6) ips = append(ips, hostIPv6)
} }
}
} else { } else {
var err error var err error
ips, err = ParseStringSliceToIPs(nodeIPs) ips, err = ParseStringSliceToIPs(nodeIPs)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment