From 127b7e311c737fb23142941d16a1b7e8cdb1cf5f Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sat, 2 May 2020 22:37:12 +0100 Subject: [PATCH] Clean up a bit --- src/multicast/multicast.go | 41 ++++++++++++++------------------------ 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/src/multicast/multicast.go b/src/multicast/multicast.go index d944b7ff..28c9b4ec 100644 --- a/src/multicast/multicast.go +++ b/src/multicast/multicast.go @@ -26,17 +26,16 @@ const ( // automatically. type Multicast struct { phony.Inbox - core *yggdrasil.Core - config *config.NodeState - log *log.Logger - sock *ipv6.PacketConn - groupAddr *net.UDPAddr - listeners map[string]*multicastInterface - listenPort uint16 - isOpen bool - interfaceMonitor *time.Timer - announcer *time.Timer - platformhandler *time.Timer + core *yggdrasil.Core + config *config.NodeState + log *log.Logger + sock *ipv6.PacketConn + groupAddr *net.UDPAddr + listeners map[string]*multicastInterface + listenPort uint16 + isOpen bool + monitor *time.Timer + platformhandler *time.Timer } type multicastInterface struct { @@ -47,15 +46,9 @@ type multicastInterface struct { zone string timer *time.Timer interval time.Duration - send chan<- beacon stop chan interface{} } -type beacon struct { - llAddr string - zone string -} - // Init prepares the multicast interface for use. func (m *Multicast) Init(core *yggdrasil.Core, state *config.NodeState, log *log.Logger, options interface{}) (err error) { m.core = core @@ -135,14 +128,10 @@ func (m *Multicast) Stop() error { func (m *Multicast) _stop() error { m.log.Infoln("Stopping multicast module") m.isOpen = false - /* - if m.monitorInterfaceChanges != nil { - m.monitorInterfaceChanges.Stop() - } - if m.sendBeacons != nil { - m.sendBeacons.Stop() - } - */ + for name := range m.listeners { + close(m.listeners[name].stop) + delete(m.listeners, name) + } if m.platformhandler != nil { m.platformhandler.Stop() } @@ -226,7 +215,7 @@ func (m *Multicast) monitorInterfaceChanges() { } } // Queue the next check. - m.interfaceMonitor = time.AfterFunc(time.Second, func() { + m.monitor = time.AfterFunc(time.Second, func() { m.Act(m, m.monitorInterfaceChanges) }) }