Bind to loopback only as last resort
This commit is contained in:
parent
1013f2f494
commit
4ce2af3bd4
|
@ -178,6 +178,7 @@ func isPrivateIP(ip_str string) bool {
|
|||
// Returns addresses from interfaces that is up
|
||||
func activeInterfaceAddresses() ([]net.Addr, error) {
|
||||
var upAddrs []net.Addr
|
||||
var loAddrs []net.Addr
|
||||
|
||||
interfaces, err := net.Interfaces()
|
||||
if err != nil {
|
||||
|
@ -195,9 +196,18 @@ func activeInterfaceAddresses() ([]net.Addr, error) {
|
|||
return nil, fmt.Errorf("Failed to get interface addresses: %v", err)
|
||||
}
|
||||
|
||||
if iface.Flags&net.FlagLoopback != 0 {
|
||||
loAddrs = append(loAddrs, addresses...)
|
||||
continue
|
||||
}
|
||||
|
||||
upAddrs = append(upAddrs, addresses...)
|
||||
}
|
||||
|
||||
if len(upAddrs) == 0 {
|
||||
return loAddrs, nil
|
||||
}
|
||||
|
||||
return upAddrs, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue