Store interface info

This commit is contained in:
Neil Alexander 2020-05-31 17:55:57 +01:00
parent de06b4656a
commit 53ab715fb4
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -32,6 +32,9 @@ func (m *Multicast) _multicastStarted() {
go func() { go func() {
defer fmt.Println("No longer listening for netlink changes") defer fmt.Println("No longer listening for netlink changes")
for { for {
current := m.config.GetCurrent()
exprs := current.MulticastInterfaces
select { select {
case change := <-linkChanges: case change := <-linkChanges:
attrs := change.Attrs() attrs := change.Attrs()
@ -56,8 +59,13 @@ func (m *Multicast) _multicastStarted() {
if add { if add {
m.Act(nil, func() { m.Act(nil, func() {
fmt.Println("Link added:", attrs.Name) fmt.Println("Link added:", attrs.Name)
if intf, err := net.InterfaceByName(attrs.Name); err == nil { if iface, err := net.InterfaceByName(attrs.Name); err == nil {
m._interfaces[attrs.Name] = intf if addrs, err := iface.Addrs(); err == nil {
m._interfaces[attrs.Name] = interfaceInfo{
iface: iface,
addrs: addrs,
}
}
} }
}) })
} else { } else {