5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-25 11:41:34 +00:00

multicast, use the prebuilt interface map when checking active listeners (#707)

This commit is contained in:
Arceliar 2020-09-27 07:16:51 -05:00 committed by GitHub
parent 48f008a8e2
commit 33e3679458
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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