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.
This commit is contained in:
Dave Collins 2015-11-03 20:32:15 -06:00
parent 23bcb367b2
commit aa0efa1f3e

View file

@ -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 {