Correctly handle RPC listen addresses with IPv6 zones.

Fixes #341.
This commit is contained in:
Josh Rickmar 2016-01-14 12:43:42 -05:00
parent c4abe025d0
commit 6af96bfdb7

View file

@ -33,6 +33,7 @@ import (
"os"
"path/filepath"
"runtime"
"strings"
"sync"
"sync/atomic"
"time"
@ -194,6 +195,16 @@ func parseListeners(addrs []string) ([]string, []string, error) {
continue
}
// Remove the IPv6 zone from the host, if present. The zone
// prevents ParseIP from correctly parsing the IP address.
// ResolveIPAddr is intentionally not used here due to the
// possibility of leaking a DNS query over Tor if the host is a
// hostname and not an IP address.
zoneIndex := strings.Index(host, "%")
if zoneIndex != -1 {
host = host[:zoneIndex]
}
// Parse the IP.
ip := net.ParseIP(host)
if ip == nil {