lncfg+config: use address string in IsLoopback

This commit is contained in:
Wilmer Paulino 2018-06-27 18:27:05 -07:00
parent 17399994e4
commit bbeb8b2ddd
No known key found for this signature in database
GPG Key ID: 6DF57B9F9514972F
3 changed files with 5 additions and 8 deletions

@ -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",