lncfg+config: use address string in IsLoopback
This commit is contained in:
parent
17399994e4
commit
bbeb8b2ddd
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user