Tidy up the terminate path a bit

This commit is contained in:
Neil Alexander 2019-07-06 12:17:40 +01:00
parent 618d46a7b3
commit 4804ce39af
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944

View File

@ -242,16 +242,9 @@ func main() {
r := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
signal.Notify(r, os.Interrupt, syscall.SIGHUP)
// Define what happens when we want to stop Yggdrasil.
terminate := func() {
n.core.Stop()
n.admin.Stop()
n.multicast.Stop()
n.tuntap.Stop()
os.Exit(0)
}
// Capture the service being stopped on Windows.
minwinsvc.SetOnExit(terminate)
minwinsvc.SetOnExit(n.shutdown)
defer n.shutdown()
// Wait for the terminate/interrupt signal. Once a signal is received, the
// deferred Stop function above will run which will shut down TUN/TAP.
for {
@ -270,7 +263,14 @@ func main() {
}
}
exit:
terminate()
}
func (n *node) shutdown() {
n.core.Stop()
n.admin.Stop()
n.multicast.Stop()
n.tuntap.Stop()
os.Exit(0)
}
func (n *node) sessionFirewall(pubkey *crypto.BoxPubKey, initiator bool) bool {