lncfg: add isIPv6Host helper to force v6 addrs through system resolver
With this commit, if --tor.active is specified, then IPv6 addresses will no longer go through the connmgr.TorLookupIP function from btcd. This function does not have proper IPv6 support and would fail with the error "tor general error". Instead, use the system resolver.
This commit is contained in:
parent
ce01cdd7d6
commit
80eb5dbece
@ -121,6 +121,12 @@ func IsLoopback(addr string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isIPv6Host returns true if the host is IPV6 and false otherwise.
|
||||||
|
func isIPv6Host(host string) bool {
|
||||||
|
// An IPv4 host without the port shouldn't have a colon.
|
||||||
|
return strings.Contains(host, ":")
|
||||||
|
}
|
||||||
|
|
||||||
// IsUnix returns true if an address describes an Unix socket address.
|
// IsUnix returns true if an address describes an Unix socket address.
|
||||||
func IsUnix(addr net.Addr) bool {
|
func IsUnix(addr net.Addr) bool {
|
||||||
return strings.HasPrefix(addr.Network(), "unix")
|
return strings.HasPrefix(addr.Network(), "unix")
|
||||||
@ -217,9 +223,10 @@ func ParseAddressString(strAddress string, defaultPort string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, we'll attempt the resolve the host. The Tor
|
// Otherwise, we'll attempt the resolve the host. The Tor
|
||||||
// resolver is unable to resolve local addresses, so we'll use
|
// resolver is unable to resolve local or IPv6 addresses, so
|
||||||
// the system resolver instead.
|
// we'll use the system resolver instead.
|
||||||
if rawHost == "" || IsLoopback(rawHost) {
|
if rawHost == "" || IsLoopback(rawHost) ||
|
||||||
|
isIPv6Host(rawHost) {
|
||||||
return net.ResolveTCPAddr("tcp", addrWithPort)
|
return net.ResolveTCPAddr("tcp", addrWithPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user