mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-07 11:22:10 +02:00
Merge pull request #6376 from ellemouton/useTCPResolverForAllInterfacesAddr
lncfg: normal TCP resolution for the all-interfaces IP
This commit is contained in:
@@ -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 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).
|
* [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).
|
||||||
|
|
||||||
* [Fixed a bug in the `btcwallet` that caused an error to be shown for
|
* [Fixed a bug in the `btcwallet` that caused an error to be shown for
|
||||||
`lncli walletbalance` in existing wallets after upgrading to
|
`lncli walletbalance` in existing wallets after upgrading to
|
||||||
@@ -220,6 +223,7 @@ gRPC performance metrics (latency to process `GetInfo`, etc)](https://github.com
|
|||||||
* Carsten Otto
|
* Carsten Otto
|
||||||
* Dan Bolser
|
* Dan Bolser
|
||||||
* Daniel McNally
|
* Daniel McNally
|
||||||
|
* Elle Mouton
|
||||||
* ErikEk
|
* ErikEk
|
||||||
* Eugene Siegel
|
* Eugene Siegel
|
||||||
* henta
|
* henta
|
||||||
|
2
go.mod
2
go.mod
@@ -4,7 +4,7 @@ require (
|
|||||||
github.com/NebulousLabs/fastrand v0.0.0-20181203155948-6fb6489aac4e // indirect
|
github.com/NebulousLabs/fastrand v0.0.0-20181203155948-6fb6489aac4e // indirect
|
||||||
github.com/NebulousLabs/go-upnp v0.0.0-20180202185039-29b680b06c82
|
github.com/NebulousLabs/go-upnp v0.0.0-20180202185039-29b680b06c82
|
||||||
github.com/Yawning/aez v0.0.0-20211027044916-e49e68abd344
|
github.com/Yawning/aez v0.0.0-20211027044916-e49e68abd344
|
||||||
github.com/btcsuite/btcd v0.22.0-beta.0.20220316175102-8d5c75c28923
|
github.com/btcsuite/btcd v0.22.0-beta.0.20220330201728-074266215c26
|
||||||
github.com/btcsuite/btcd/btcec/v2 v2.1.3
|
github.com/btcsuite/btcd/btcec/v2 v2.1.3
|
||||||
github.com/btcsuite/btcd/btcutil v1.1.1
|
github.com/btcsuite/btcd/btcutil v1.1.1
|
||||||
github.com/btcsuite/btcd/btcutil/psbt v1.1.2
|
github.com/btcsuite/btcd/btcutil/psbt v1.1.2
|
||||||
|
3
go.sum
3
go.sum
@@ -74,8 +74,9 @@ github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13P
|
|||||||
github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M=
|
github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M=
|
||||||
github.com/btcsuite/btcd v0.22.0-beta.0.20220204213055-eaf0459ff879/go.mod h1:osu7EoKiL36UThEgzYPqdRaxeo0NU8VoXqgcnwpey0g=
|
github.com/btcsuite/btcd v0.22.0-beta.0.20220204213055-eaf0459ff879/go.mod h1:osu7EoKiL36UThEgzYPqdRaxeo0NU8VoXqgcnwpey0g=
|
||||||
github.com/btcsuite/btcd v0.22.0-beta.0.20220207191057-4dc4ff7963b4/go.mod h1:7alexyj/lHlOtr2PJK7L/+HDJZpcGDn/pAU98r7DY08=
|
github.com/btcsuite/btcd v0.22.0-beta.0.20220207191057-4dc4ff7963b4/go.mod h1:7alexyj/lHlOtr2PJK7L/+HDJZpcGDn/pAU98r7DY08=
|
||||||
github.com/btcsuite/btcd v0.22.0-beta.0.20220316175102-8d5c75c28923 h1:6H47xWODLXYDuzHapvx4dauPqFjegX4+rHgUkFQPvfw=
|
|
||||||
github.com/btcsuite/btcd v0.22.0-beta.0.20220316175102-8d5c75c28923/go.mod h1:taIcYprAW2g6Z9S0gGUxyR+zDwimyDMK5ePOX+iJ2ds=
|
github.com/btcsuite/btcd v0.22.0-beta.0.20220316175102-8d5c75c28923/go.mod h1:taIcYprAW2g6Z9S0gGUxyR+zDwimyDMK5ePOX+iJ2ds=
|
||||||
|
github.com/btcsuite/btcd v0.22.0-beta.0.20220330201728-074266215c26 h1:dgH5afJcotX4eXo7+bXp8Z7lOw0FyVxXQwvtkN+jab4=
|
||||||
|
github.com/btcsuite/btcd v0.22.0-beta.0.20220330201728-074266215c26/go.mod h1:taIcYprAW2g6Z9S0gGUxyR+zDwimyDMK5ePOX+iJ2ds=
|
||||||
github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA=
|
github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA=
|
||||||
github.com/btcsuite/btcd/btcec/v2 v2.1.1/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE=
|
github.com/btcsuite/btcd/btcec/v2 v2.1.1/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE=
|
||||||
github.com/btcsuite/btcd/btcec/v2 v2.1.3 h1:xM/n3yIhHAhHy04z4i43C8p4ehixJZMsnrVJkgl+MTE=
|
github.com/btcsuite/btcd/btcec/v2 v2.1.3 h1:xM/n3yIhHAhHy04z4i43C8p4ehixJZMsnrVJkgl+MTE=
|
||||||
|
@@ -14,10 +14,6 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/tor"
|
"github.com/lightningnetwork/lnd/tor"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
loopBackAddrs = []string{"localhost", "127.0.0.1", "[::1]"}
|
|
||||||
)
|
|
||||||
|
|
||||||
// TCPResolver is a function signature that resolves an address on a given
|
// TCPResolver is a function signature that resolves an address on a given
|
||||||
// network.
|
// network.
|
||||||
type TCPResolver = func(network, addr string) (*net.TCPAddr, error)
|
type TCPResolver = func(network, addr string) (*net.TCPAddr, error)
|
||||||
@@ -112,14 +108,18 @@ func TLSListenOnAddress(addr net.Addr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IsLoopback returns true if an address describes a loopback interface.
|
// IsLoopback returns true if an address describes a loopback interface.
|
||||||
func IsLoopback(addr string) bool {
|
func IsLoopback(host string) bool {
|
||||||
for _, loopback := range loopBackAddrs {
|
if strings.Contains(host, "localhost") {
|
||||||
if strings.Contains(addr, loopback) {
|
return true
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
rawHost, _, _ := net.SplitHostPort(host)
|
||||||
|
addr := net.ParseIP(rawHost)
|
||||||
|
if addr == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return addr.IsLoopback()
|
||||||
}
|
}
|
||||||
|
|
||||||
// isIPv6Host returns true if the host is IPV6 and false otherwise.
|
// isIPv6Host returns true if the host is IPV6 and false otherwise.
|
||||||
@@ -134,6 +134,16 @@ func isIPv6Host(host string) bool {
|
|||||||
return v6Addr.To4() == nil
|
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.
|
// 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")
|
||||||
@@ -230,17 +240,18 @@ 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 or IPv6 addresses, so
|
// resolver is unable to resolve local addresses,
|
||||||
// we'll use the system resolver instead.
|
// IPv6 addresses, or the all-interfaces address, so we'll use
|
||||||
|
// the system resolver instead for those.
|
||||||
if rawHost == "" || IsLoopback(rawHost) ||
|
if rawHost == "" || IsLoopback(rawHost) ||
|
||||||
isIPv6Host(rawHost) {
|
isIPv6Host(rawHost) || isUnspecifiedHost(rawHost) {
|
||||||
|
|
||||||
return net.ResolveTCPAddr("tcp", addrWithPort)
|
return net.ResolveTCPAddr("tcp", addrWithPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we've reached this point, then it's possible that this
|
// If we've reached this point, then it's possible that this
|
||||||
// resolve returns an error if it isn't able to resolve the
|
// 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
|
// be resolved by Tor. In order to handle this case, we'll fall
|
||||||
// back to the normal system resolver if we fail with an
|
// back to the normal system resolver if we fail with an
|
||||||
// identifiable error.
|
// identifiable error.
|
||||||
|
Reference in New Issue
Block a user