multicast, use the prebuilt interface map when checking active listeners

This commit is contained in:
Arceliar 2020-05-31 11:39:32 -05:00 committed by Neil Alexander
parent 6995b989e3
commit e59756224f
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -201,17 +201,13 @@ func (m *Multicast) _announce() {
continue
}
// Find the interface that matches the listener
if intf, err := net.InterfaceByName(name); err == nil {
if addrs, err := intf.Addrs(); err == nil {
// Loop through the addresses attached to that listener and see if any
// of them match the current address of the listener
for _, addr := range addrs {
if ip, _, err := net.ParseCIDR(addr.String()); err == nil {
// Does the interface address match our listener address?
if ip.Equal(listenaddr.IP) {
found = true
break
}
if info, ok := m._interfaces[name]; ok {
for _, addr := range info.addrs {
if ip, _, err := net.ParseCIDR(addr.String()); err == nil {
// Does the interface address match our listener address?
if ip.Equal(listenaddr.IP) {
found = true
break
}
}
}