fix(portforward): trigger after VPN restart

This commit is contained in:
Quentin McGaw
2023-09-28 14:00:58 +00:00
parent a194906bdd
commit d4df87286e
10 changed files with 112 additions and 79 deletions

View File

@@ -71,7 +71,7 @@ func (l *Loop) Run(ctx context.Context, done chan<- struct{}) {
case <-tunnelReady:
go l.onTunnelUp(openvpnCtx, tunnelUpData)
case <-ctx.Done():
l.cleanup(portForwarder.Name())
l.cleanup()
openvpnCancel()
<-waitError
close(waitError)
@@ -79,7 +79,7 @@ func (l *Loop) Run(ctx context.Context, done chan<- struct{}) {
case <-l.stop:
l.userTrigger = true
l.logger.Info("stopping")
l.cleanup(portForwarder.Name())
l.cleanup()
openvpnCancel()
<-waitError
// do not close waitError or the waitError
@@ -92,7 +92,7 @@ func (l *Loop) Run(ctx context.Context, done chan<- struct{}) {
case err := <-waitError: // unexpected error
l.statusManager.Lock() // prevent SetStatus from running in parallel
l.cleanup(portForwarder.Name())
l.cleanup()
openvpnCancel()
l.statusManager.SetStatus(constants.Crashed)
l.logAndWait(ctx, err)