lncfg: normal TCP resolution for unspecified IPs

Use normal TCP resolution for any unspecified IP (0.0.0.0 or ::) instead
of using the Tor resolver.
This commit is contained in:
Elle Mouton 2022-03-28 12:47:23 +02:00
parent ba83c11a6f
commit c6e96c67ce
No known key found for this signature in database
GPG key ID: D7D916376026F177
2 changed files with 19 additions and 4 deletions

View file

@ -67,6 +67,9 @@ then watch it on chain. Taproot script spends are also supported through the
* [Fixed node shutdown in forward interceptor itests](https://github.com/lightningnetwork/lnd/pull/6362).
* [Fixed a bug that would cause lnd to be unable to parse certain PSBT blobs](https://github.com/lightningnetwork/lnd/pull/6383).
* [Use normal TCP resolution, instead of Tor DNS resolution, for addresses
using the all-interfaces IP](https://github.com/lightningnetwork/lnd/pull/6376).
## Misc
@ -213,6 +216,7 @@ gRPC performance metrics (latency to process `GetInfo`, etc)](https://github.com
* Carsten Otto
* Dan Bolser
* Daniel McNally
* Elle Mouton
* ErikEk
* Eugene Siegel
* henta

View file

@ -134,6 +134,16 @@ func isIPv6Host(host string) bool {
return v6Addr.To4() == nil
}
// isUnspecifiedHost returns true if the host IP is considered unspecified.
func isUnspecifiedHost(host string) bool {
addr := net.ParseIP(host)
if addr == nil {
return false
}
return addr.IsUnspecified()
}
// IsUnix returns true if an address describes an Unix socket address.
func IsUnix(addr net.Addr) bool {
return strings.HasPrefix(addr.Network(), "unix")
@ -230,17 +240,18 @@ func ParseAddressString(strAddress string, defaultPort string,
}
// Otherwise, we'll attempt the resolve the host. The Tor
// resolver is unable to resolve local or IPv6 addresses, so
// we'll use the system resolver instead.
// resolver is unable to resolve local addresses,
// IPv6 addresses, or the all-interfaces address, so we'll use
// the system resolver instead for those.
if rawHost == "" || IsLoopback(rawHost) ||
isIPv6Host(rawHost) {
isIPv6Host(rawHost) || isUnspecifiedHost(rawHost) {
return net.ResolveTCPAddr("tcp", addrWithPort)
}
// If we've reached this point, then it's possible that this
// resolve returns an error if it isn't able to resolve the
// host. For eaxmple, local entries in /etc/hosts will fail to
// host. For example, local entries in /etc/hosts will fail to
// be resolved by Tor. In order to handle this case, we'll fall
// back to the normal system resolver if we fail with an
// identifiable error.