Skip to content

Commit

Permalink
Correctly handle RPC listen addresses with IPv6 zones.
Browse files Browse the repository at this point in the history
Fixes #341.
  • Loading branch information
jrick committed Jan 14, 2016
1 parent c4abe02 commit 6af96bf
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"os"
"path/filepath"
"runtime"
"strings"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 6af96bf

Please sign in to comment.