fix(publicip): abort ip data fetch if vpn context is canceled
- Prevents requesting the public IP address N times after N VPN failures - Fetching runs with a context local to the 'single run' - Single run writes single run result to a channel back to the caller, RunOnce is now blocking
This commit is contained in:
@@ -29,7 +29,10 @@ func (l *Loop) onTunnelUp(ctx context.Context, data tunnelUpData) {
|
||||
_, _ = l.dnsLooper.ApplyStatus(ctx, constants.Running)
|
||||
}
|
||||
|
||||
l.publicip.StartSingleRun()
|
||||
err := l.publicip.RunOnce(ctx)
|
||||
if err != nil {
|
||||
l.logger.Error("getting public IP address information: " + err.Error())
|
||||
}
|
||||
|
||||
if l.versionInfo {
|
||||
l.versionInfo = false // only get the version information once
|
||||
@@ -41,7 +44,7 @@ func (l *Loop) onTunnelUp(ctx context.Context, data tunnelUpData) {
|
||||
}
|
||||
}
|
||||
|
||||
err := l.startPortForwarding(data)
|
||||
err = l.startPortForwarding(data)
|
||||
if err != nil {
|
||||
l.logger.Error(err.Error())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user