5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-22 10:40:27 +00:00

save only the link-local addresses for multicast

This commit is contained in:
Arceliar 2020-05-03 05:06:59 -05:00
parent de79401bb2
commit 95f4ec52a4

View File

@ -292,15 +292,15 @@ func (m *Multicast) _updateInterfaces() {
aInfo.addrs, _ = iface.Addrs() aInfo.addrs, _ = iface.Addrs()
aInfo.time = time.Now() aInfo.time = time.Now()
} }
hasLLAddr := false lladdrs := aInfo.addrs[:0]
for _, addr := range aInfo.addrs { for _, addr := range aInfo.addrs {
addrIP, _, _ := net.ParseCIDR(addr.String()) addrIP, _, _ := net.ParseCIDR(addr.String())
if addrIP.To4() == nil && addrIP.IsLinkLocalUnicast() { if addrIP.To4() == nil && addrIP.IsLinkLocalUnicast() {
hasLLAddr = true lladdrs = append(lladdrs, addr)
break
} }
} }
if !hasLLAddr { aInfo.addrs = lladdrs
if len(lladdrs) == 0 {
// Ignore interfaces without link-local addresses // Ignore interfaces without link-local addresses
continue continue
} }