fix: suppress proxy blocking during grace period after network change - #184
Open
derbauer97 wants to merge 1 commit into
Open
fix: suppress proxy blocking during grace period after network change#184derbauer97 wants to merge 1 commit into
derbauer97 wants to merge 1 commit into
Conversation
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>
derbauer97
requested review from
camh-,
juliaogris,
marcelocantos and
samuong
as code owners
July 16, 2026 11:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 viablockProxy(). SinceaddrsChanged()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.ALPACA_GRACE_PERIOD(seconds)0(disabled, preserves existing behavior)3to enableTesting
TestBlockProxySuppressedDuringGracePeriodFixes #183