Merge pull request #2895 from hashicorp/pr/2878

Adds brackets around ipv6 addresses for flood joins.
This commit is contained in:
James Phillips 2017-04-12 10:04:39 -07:00 committed by GitHub
commit 05fe2d62e2
1 changed files with 10 additions and 0 deletions

View File

@ -69,6 +69,16 @@ 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 {
// If we have an IPv6 address, we should add brackets,
// single globalSerf.Join expects that.
if ip := net.ParseIP(addr); ip != nil {
if ip.To4() == nil {
addr = fmt.Sprintf("[%s]", addr)
}
} else {
logger.Printf("[DEBUG] consul: Failed to parse IP %s", addr)
}
}
// Do the join!