Changed due to review comments

This commit is contained in:
Jochen Hiller 2020-05-31 13:15:43 +02:00 committed by John Beisley
parent b987734dc3
commit 49508fba00

View File

@ -48,8 +48,8 @@ func localIPv4MCastAddrs() ([]string, error) {
// Find the set of addresses to listen on.
var addrs []string
for _, iface := range ifaces {
if iface.Flags&net.FlagMulticast == 0 {
// Does not support multicast.
if iface.Flags&net.FlagMulticast == 0 || iface.Flags&net.FlagLoopback != 0 {
// Does not support multicast or is a loopback address.
continue
}
ifaceAddrs, err := iface.Addrs()
@ -67,11 +67,6 @@ func localIPv4MCastAddrs() ([]string, error) {
// Not IPv4.
continue
}
// Fix #33: consider NOT loopback IP addresses
if addr.IP.IsLoopback() {
// do not use local address
continue
}
addrs = append(addrs, addr.IP.String())
}
}