Skip to content

fix: suppress proxy blocking during grace period after network change - #184

Open
derbauer97 wants to merge 1 commit into
samuong:masterfrom
derbauer97:fix/blocklist-grace-period-after-network-change
Open

fix: suppress proxy blocking during grace period after network change#184
derbauer97 wants to merge 1 commit into
samuong:masterfrom
derbauer97:fix/blocklist-grace-period-after-network-change

Conversation

@derbauer97

Copy link
Copy Markdown

Problem

After switching from a network where the corporate proxy is unreachable (e.g. mobile hotspot) back to the corporate network, alpaca can get stuck in DIRECT mode for up to 5 minutes despite the proxy being reachable again.

Root Cause

When checkForUpdates() detects a network change and resets the blocklist, concurrent requests that fail (because the network is not yet fully stable) immediately re-block the proxy via blockProxy(). Since addrsChanged() no longer returns true (addresses haven't changed since the reset), the blocklist is never cleared again until the 5-minute TTL expires.

Fix

Add a configurable grace period after network changes during which blockProxy() calls are suppressed. This gives the network time to stabilize before alpaca evaluates proxy reachability.

  • New env var: ALPACA_GRACE_PERIOD (seconds)
  • Default: 0 (disabled, preserves existing behavior)
  • Set to e.g. 3 to enable

Testing

  • Added TestBlockProxySuppressedDuringGracePeriod
  • All existing tests pass
  • Tested manually with repeated hotspot ↔ corporate network switches on macOS

Fixes #183

After a network change is detected (addrsChanged returns true),
checkForUpdates resets the blocklist. However, concurrent requests
that fail because the network is not yet fully stable can immediately
re-block the proxy, causing alpaca to stay in DIRECT mode for up to
5 minutes.

Add a configurable grace period after network changes during which
blockProxy() calls are suppressed. This gives the network time to
stabilize before alpaca starts evaluating proxy reachability.

Configurable via ALPACA_GRACE_PERIOD env var (seconds).
Default: 0 (disabled). Set to e.g. 3 to enable.

Fixes: samuong#183
Signed-off-by: FlorianFlBauer <florian.fl.bauer@deutschebahn.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proxy blocklist race after network change with local PAC file

1 participant