fix(port-forwarding): loop exit from vpn loop
This commit is contained in:
@@ -52,10 +52,14 @@ func (l *Loop) Run(ctx context.Context, done chan<- struct{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stayHere := true
|
stayHere := true
|
||||||
|
stopped := false
|
||||||
for stayHere {
|
for stayHere {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
pfCancel()
|
pfCancel()
|
||||||
|
if stopped {
|
||||||
|
return
|
||||||
|
}
|
||||||
<-errorCh
|
<-errorCh
|
||||||
close(errorCh)
|
close(errorCh)
|
||||||
close(portCh)
|
close(portCh)
|
||||||
@@ -77,6 +81,7 @@ func (l *Loop) Run(ctx context.Context, done chan<- struct{}) {
|
|||||||
l.firewallBlockPort(ctx)
|
l.firewallBlockPort(ctx)
|
||||||
l.state.SetPortForwarded(0)
|
l.state.SetPortForwarded(0)
|
||||||
l.stopped <- struct{}{}
|
l.stopped <- struct{}{}
|
||||||
|
stopped = true
|
||||||
case port := <-portCh:
|
case port := <-portCh:
|
||||||
l.logger.Info("port forwarded is " + strconv.Itoa(int(port)))
|
l.logger.Info("port forwarded is " + strconv.Itoa(int(port)))
|
||||||
l.firewallBlockPort(ctx)
|
l.firewallBlockPort(ctx)
|
||||||
|
|||||||
Reference in New Issue
Block a user