Fix ipv6 join failure

This commit is contained in:
Wim 2017-04-06 22:53:10 +02:00
parent fbbdaf6949
commit 7c8f25c36e

View file

@ -69,6 +69,17 @@ func FloodJoins(logger *log.Logger, portFn FloodPortFn,
// leave it blank to behave as if we just supplied an address.
if port, ok := portFn(server); ok {
addr = net.JoinHostPort(addr, fmt.Sprintf("%d", port))
} else {
// globalSerf.Join expects bracketed ipv6 addresses
ip := net.ParseIP(addr)
if ip == nil {
// should never happen
logger.Printf("[DEBUG] consul: Failed to parse IP %s", addr)
}
// If we have an IPv6 address, we should add brackets
if ip.To4() == nil {
addr = fmt.Sprintf("[%s]", addr)
}
}
// Do the join!