wait for goroutines to finish and for tun to actually be closed

This commit is contained in:
JackDoan
2026-04-16 13:19:25 -05:00
parent 183c1e3cfd
commit 6b2e6d9f55
6 changed files with 57 additions and 16 deletions

View File

@@ -65,8 +65,11 @@ type ControlHostInfo struct {
}
// Start actually runs nebula, this is a nonblocking call.
// The returned function can be used to wait for nebula to fully stop.
func (c *Control) Start() (func(), error) {
// The returned function blocks until nebula has fully stopped and returns the
// first fatal reader error (if any). A nil error means nebula shut down
// gracefully; a non-nil error means a reader hit an unexpected failure that
// triggered the shutdown.
func (c *Control) Start() (func() error, error) {
c.stateLock.Lock()
if c.state != Stopped {
c.stateLock.Unlock()
@@ -97,6 +100,8 @@ func (c *Control) Start() (func(), error) {
c.lighthouseStart()
}
c.f.triggerShutdown = c.Stop
// Start reading packets.
c.state = Started
c.stateLock.Unlock()