diff --git a/src/yggdrasil/core.go b/src/yggdrasil/core.go index 598d8121..cdc8ad44 100644 --- a/src/yggdrasil/core.go +++ b/src/yggdrasil/core.go @@ -194,7 +194,9 @@ func (c *Core) _stop() { if c.addPeerTimer != nil { c.addPeerTimer.Stop() } + c.link.stop() for _, peer := range c.GetPeers() { c.DisconnectPeer(peer.Port) } + c.log.Infoln("Stopped") } diff --git a/src/yggdrasil/link.go b/src/yggdrasil/link.go index bdf15547..df73cc4c 100644 --- a/src/yggdrasil/link.go +++ b/src/yggdrasil/link.go @@ -134,6 +134,13 @@ func (l *link) create(msgIO linkInterfaceMsgIO, name, linkType, local, remote st return &intf, nil } +func (l *link) stop() error { + if err := l.tcp.stop(); err != nil { + return err + } + return nil +} + func (intf *linkInterface) handler() error { // TODO split some of this into shorter functions, so it's easier to read, and for the FIXME duplicate peer issue mentioned later myLinkPub, myLinkPriv := crypto.NewBoxKeys() diff --git a/src/yggdrasil/tcp.go b/src/yggdrasil/tcp.go index 93e39e40..a8c23623 100644 --- a/src/yggdrasil/tcp.go +++ b/src/yggdrasil/tcp.go @@ -96,6 +96,13 @@ func (t *tcp) init(l *link) error { return nil } +func (t *tcp) stop() error { + for _, listener := range t.listeners { + close(listener.Stop) + } + return nil +} + func (t *tcp) reconfigure() { t.link.core.config.Mutex.RLock() added := util.Difference(t.link.core.config.Current.Listen, t.link.core.config.Previous.Listen)