From d38ceaa3ea289341091f4f7c8186c6c1f22dd54b Mon Sep 17 00:00:00 2001 From: Wim Date: Thu, 6 Apr 2017 22:53:10 +0200 Subject: [PATCH 1/2] Fix ipv6 join failure --- consul/servers/serf_flooder.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/consul/servers/serf_flooder.go b/consul/servers/serf_flooder.go index 74d7bb0c06..834c67f768 100644 --- a/consul/servers/serf_flooder.go +++ b/consul/servers/serf_flooder.go @@ -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! From 1ec16b924322ec7c7fbd8466b7b78ffb2d59eac5 Mon Sep 17 00:00:00 2001 From: James Phillips Date: Wed, 12 Apr 2017 10:02:42 -0700 Subject: [PATCH 2/2] Tweaks error handling case to not panic further down. --- consul/servers/serf_flooder.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/consul/servers/serf_flooder.go b/consul/servers/serf_flooder.go index 834c67f768..4a2f83ce45 100644 --- a/consul/servers/serf_flooder.go +++ b/consul/servers/serf_flooder.go @@ -70,16 +70,15 @@ func FloodJoins(logger *log.Logger, portFn FloodPortFn, 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 + // 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) } - // If we have an IPv6 address, we should add brackets - if ip.To4() == nil { - addr = fmt.Sprintf("[%s]", addr) - } } // Do the join!