From aa0efa1f3ec03b8d0d77e3b1caf55dfb178dbf07 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Tue, 3 Nov 2015 20:32:15 -0600 Subject: [PATCH] server: Allow IPv6 addresses with zone id. This modifies the IP parsing code to work with IPv6 zone ids. This is needed since the net.ParseIP function does not allow zone ids even though net.Listen does. --- server.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server.go b/server.go index 0568ae16..a250df1a 100644 --- a/server.go +++ b/server.go @@ -14,6 +14,7 @@ import ( "net" "runtime" "strconv" + "strings" "sync" "sync/atomic" "time" @@ -2075,6 +2076,13 @@ func parseListeners(addrs []string) ([]string, []string, bool, error) { continue } + // Strip IPv6 zone id if present since net.ParseIP does not + // handle it. + zoneIndex := strings.LastIndex(host, "%") + if zoneIndex > 0 { + host = host[:zoneIndex] + } + // Parse the IP. ip := net.ParseIP(host) if ip == nil {