diff --git a/src/multicast/multicast.go b/src/multicast/multicast.go index 08b7180e..63156d82 100644 --- a/src/multicast/multicast.go +++ b/src/multicast/multicast.go @@ -7,6 +7,7 @@ import ( "regexp" "time" + "github.com/Arceliar/phony" "github.com/gologme/log" "github.com/yggdrasil-network/yggdrasil-go/src/config" @@ -19,6 +20,7 @@ import ( // configured multicast interface, Yggdrasil will attempt to peer with that node // automatically. type Multicast struct { + phony.Inbox core *yggdrasil.Core config *config.NodeState log *log.Logger @@ -66,8 +68,8 @@ func (m *Multicast) Start() error { m.isOpen = true go m.listen() - m.multicastStarted() - m.announce() + m.Act(m, m.multicastStarted) + m.Act(m, m.announce) return nil } @@ -243,7 +245,9 @@ func (m *Multicast) announce() { break } } - m.announcer = time.AfterFunc(time.Second*15, m.announce) + m.announcer = time.AfterFunc(time.Second*15, func() { + m.Act(m, m.announce) + }) } func (m *Multicast) listen() { diff --git a/src/multicast/multicast_darwin.go b/src/multicast/multicast_darwin.go index 6fdccb2b..4cfef9e9 100644 --- a/src/multicast/multicast_darwin.go +++ b/src/multicast/multicast_darwin.go @@ -39,7 +39,9 @@ func (m *Multicast) multicastStarted() { break } } - m.platformhandler = time.AfterFunc(time.Minute, m.multicastStarted) + m.platformhandler = time.AfterFunc(time.Minute, func() { + m.Act(m, m.multicastStarted) + }) } func (m *Multicast) multicastReuse(network string, address string, c syscall.RawConn) error {