diff --git a/config.go b/config.go index 515970f1..949f2503 100644 --- a/config.go +++ b/config.go @@ -875,10 +875,7 @@ func loadConfig() (*config, error) { // inbound support is enabled. if cfg.Tor.V2 || cfg.Tor.V3 { for _, addr := range cfg.Listeners { - // Due to the addresses being normalized above, we can - // skip checking the error. - host, _, _ := net.SplitHostPort(addr.String()) - if lncfg.IsLoopback(addr) { + if lncfg.IsLoopback(addr.String()) { continue } diff --git a/lncfg/address.go b/lncfg/address.go index 25d07fe6..fb4deb77 100644 --- a/lncfg/address.go +++ b/lncfg/address.go @@ -52,7 +52,7 @@ func EnforceSafeAuthentication(addrs []net.Addr, macaroonsActive bool) error { // on. If it's a localhost address, we'll skip it, otherwise, we'll // return an error if macaroons are inactive. for _, addr := range addrs { - if IsLoopback(addr) || IsUnix(addr) { + if IsLoopback(addr.String()) || IsUnix(addr) { continue } @@ -79,9 +79,9 @@ func TlsListenOnAddress(addr net.Addr, } // IsLoopback returns true if an address describes a loopback interface. -func IsLoopback(addr net.Addr) bool { +func IsLoopback(addr string) bool { for _, loopback := range loopBackAddrs { - if strings.Contains(addr.String(), loopback) { + if strings.Contains(addr, loopback) { return true } } diff --git a/lncfg/address_test.go b/lncfg/address_test.go index ff2db4ac..92ed488d 100644 --- a/lncfg/address_test.go +++ b/lncfg/address_test.go @@ -100,7 +100,7 @@ func TestAddresses(t *testing.T) { netAddr.Network(), netAddr.String(), ) } - isAddrLoopback := IsLoopback(normalized[0]) + isAddrLoopback := IsLoopback(normalized[0].String()) if testVector.isLoopback != isAddrLoopback { t.Fatalf("#%v: mismatched loopback detection: expected "+ "%v, got %v for addr %s",