Add a context object in nebula.Main to clean up on error (#550)

This commit is contained in:
brad-defined 2021-11-02 14:14:26 -04:00 committed by GitHub
parent 32cd9a93f1
commit 6ae8ba26f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 139 additions and 40 deletions

View file

@ -1,6 +1,7 @@
package nebula
import (
"context"
"net"
"os"
"os/signal"
@ -17,6 +18,7 @@ import (
type Control struct {
f *Interface
l *logrus.Logger
cancel context.CancelFunc
sshStart func()
statsStart func()
dnsStart func()
@ -57,6 +59,7 @@ func (c *Control) Start() {
func (c *Control) Stop() {
//TODO: stop tun and udp routines, the lock on hostMap effectively does that though
c.CloseAllTunnels(false)
c.cancel()
c.l.Info("Goodbye")
}