Fix comments and add check in case of IPv6 only node

Signed-off-by: Roberto Bonafiglia <roberto.bonafiglia@suse.com>
This commit is contained in:
Roberto Bonafiglia 2022-08-03 14:20:42 +02:00 committed by Roberto Bonafiglia
parent d90ba30353
commit abdf0c7319
2 changed files with 7 additions and 4 deletions

View File

@ -38,7 +38,7 @@ func getIPFromInterface(ifaceName string) (string, error) {
if err != nil {
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.IsGlobalUnicast() {
globalUnicastsIPv6 = append(globalUnicastsIPv6, ip.String())

View File

@ -142,10 +142,13 @@ func GetHostnameAndIPs(name string, nodeIPs cli.StringSlice) (string, []net.IP,
return "", nil, err
}
ips = append(ips, hostIP)
// If IPv6 it's an IPv6 only node
if hostIP.To4() != nil {
hostIPv6, err := apinet.ResolveBindAddress(net.IPv6loopback)
if err == nil && !hostIPv6.Equal(hostIP) {
ips = append(ips, hostIPv6)
}
}
} else {
var err error
ips, err = ParseStringSliceToIPs(nodeIPs)