mirror of
https://github.com/status-im/consul.git
synced 2025-01-24 04:31:12 +00:00
Bind to loopback only as last resort
This commit is contained in:
parent
c94f78e92f
commit
54ea982b02
@ -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…
x
Reference in New Issue
Block a user