diff --git a/src/yggdrasil/admin.go b/src/yggdrasil/admin.go index db856296..5524fe25 100644 --- a/src/yggdrasil/admin.go +++ b/src/yggdrasil/admin.go @@ -57,17 +57,15 @@ func (a *admin) init(c *Core) { a.reconfigure = make(chan chan error, 1) go func() { for { - select { - case e := <-a.reconfigure: - a.core.configMutex.RLock() - if a.core.config.AdminListen != a.core.configOld.AdminListen { - a.listenaddr = a.core.config.AdminListen - a.close() - a.start() - } - a.core.configMutex.RUnlock() - e <- nil + e := <-a.reconfigure + a.core.configMutex.RLock() + if a.core.config.AdminListen != a.core.configOld.AdminListen { + a.listenaddr = a.core.config.AdminListen + a.close() + a.start() } + a.core.configMutex.RUnlock() + e <- nil } }() a.core.configMutex.RLock() diff --git a/src/yggdrasil/dht.go b/src/yggdrasil/dht.go index bba6dfc7..5427aca9 100644 --- a/src/yggdrasil/dht.go +++ b/src/yggdrasil/dht.go @@ -82,10 +82,8 @@ func (t *dht) init(c *Core) { t.reconfigure = make(chan chan error, 1) go func() { for { - select { - case e := <-t.reconfigure: - e <- nil - } + e := <-t.reconfigure + e <- nil } }() t.nodeID = *t.core.GetNodeID() diff --git a/src/yggdrasil/multicast.go b/src/yggdrasil/multicast.go index 40878951..08f0954e 100644 --- a/src/yggdrasil/multicast.go +++ b/src/yggdrasil/multicast.go @@ -25,13 +25,11 @@ func (m *multicast) init(core *Core) { m.reconfigure = make(chan chan error, 1) go func() { for { - select { - case e := <-m.reconfigure: - m.myAddrMutex.Lock() - m.myAddr = m.core.tcp.getAddr() - m.myAddrMutex.Unlock() - e <- nil - } + e := <-m.reconfigure + m.myAddrMutex.Lock() + m.myAddr = m.core.tcp.getAddr() + m.myAddrMutex.Unlock() + e <- nil } }() m.groupAddr = "[ff02::114]:9001" diff --git a/src/yggdrasil/peer.go b/src/yggdrasil/peer.go index 98cbe02f..c83504fc 100644 --- a/src/yggdrasil/peer.go +++ b/src/yggdrasil/peer.go @@ -35,10 +35,8 @@ func (ps *peers) init(c *Core) { ps.reconfigure = make(chan chan error, 1) go func() { for { - select { - case e := <-ps.reconfigure: - e <- nil - } + e := <-ps.reconfigure + e <- nil } }() ps.allowedEncryptionPublicKeys = make(map[crypto.BoxPubKey]struct{}) diff --git a/src/yggdrasil/search.go b/src/yggdrasil/search.go index 8106fb70..c391dda2 100644 --- a/src/yggdrasil/search.go +++ b/src/yggdrasil/search.go @@ -53,10 +53,8 @@ func (s *searches) init(core *Core) { s.reconfigure = make(chan chan error, 1) go func() { for { - select { - case e := <-s.reconfigure: - e <- nil - } + e := <-s.reconfigure + e <- nil } }() s.searches = make(map[crypto.NodeID]*searchInfo) diff --git a/src/yggdrasil/session.go b/src/yggdrasil/session.go index 3cd1cf7b..e29cd4fa 100644 --- a/src/yggdrasil/session.go +++ b/src/yggdrasil/session.go @@ -131,21 +131,19 @@ func (ss *sessions) init(core *Core) { ss.reconfigure = make(chan chan error, 1) go func() { for { - select { - case e := <-ss.reconfigure: - responses := make(map[crypto.Handle]chan error) - for index, session := range ss.sinfos { - responses[index] = make(chan error) - session.reconfigure <- responses[index] - } - for _, response := range responses { - if err := <-response; err != nil { - e <- err - continue - } - } - e <- nil + e := <-ss.reconfigure + responses := make(map[crypto.Handle]chan error) + for index, session := range ss.sinfos { + responses[index] = make(chan error) + session.reconfigure <- responses[index] } + for _, response := range responses { + if err := <-response; err != nil { + e <- err + continue + } + } + e <- nil } }() ss.permShared = make(map[crypto.BoxPubKey]*crypto.BoxSharedKey) diff --git a/src/yggdrasil/tcp.go b/src/yggdrasil/tcp.go index b47b5531..9cab9ea2 100644 --- a/src/yggdrasil/tcp.go +++ b/src/yggdrasil/tcp.go @@ -90,18 +90,16 @@ func (iface *tcpInterface) init(core *Core) (err error) { iface.reconfigure = make(chan chan error, 1) go func() { for { - select { - case e := <-iface.reconfigure: - iface.core.configMutex.RLock() - updated := iface.core.config.Listen != iface.core.configOld.Listen - iface.core.configMutex.RUnlock() - if updated { - iface.serv_stop <- true - iface.serv.Close() - e <- iface.listen() - } else { - e <- nil - } + e := <-iface.reconfigure + iface.core.configMutex.RLock() + updated := iface.core.config.Listen != iface.core.configOld.Listen + iface.core.configMutex.RUnlock() + if updated { + iface.serv_stop <- true + iface.serv.Close() + e <- iface.listen() + } else { + e <- nil } } }() diff --git a/src/yggdrasil/tun.go b/src/yggdrasil/tun.go index 46fabbc7..c0a71396 100644 --- a/src/yggdrasil/tun.go +++ b/src/yggdrasil/tun.go @@ -46,19 +46,17 @@ func (tun *tunAdapter) init(core *Core, send chan<- []byte, recv <-chan []byte) tun.icmpv6.init(tun) go func() { for { - select { - case e := <-tun.reconfigure: - tun.core.configMutex.RLock() - updated := tun.core.config.IfName != tun.core.configOld.IfName || - tun.core.config.IfTAPMode != tun.core.configOld.IfTAPMode || - tun.core.config.IfMTU != tun.core.configOld.IfMTU - tun.core.configMutex.RUnlock() - if updated { - tun.core.log.Println("Reconfiguring TUN/TAP is not supported yet") - e <- nil - } else { - e <- nil - } + e := <-tun.reconfigure + tun.core.configMutex.RLock() + updated := tun.core.config.IfName != tun.core.configOld.IfName || + tun.core.config.IfTAPMode != tun.core.configOld.IfTAPMode || + tun.core.config.IfMTU != tun.core.configOld.IfMTU + tun.core.configMutex.RUnlock() + if updated { + tun.core.log.Println("Reconfiguring TUN/TAP is not supported yet") + e <- nil + } else { + e <- nil } } }()