fix(smart): stop rapid proxy rotation on successful dials - #15
Open
qoli wants to merge 3 commits into
Open
Conversation
qoli
force-pushed
the
codex/preserve-smart-connections
branch
from
September 1, 2026 07:51
5b54ff3 to
5185f6e
Compare
Smart should preserve connection continuity while it learns proxy quality and only evict traffic after degradation is observed. The success-path closeSameConnection call violates that model by making every newly completed dial authoritative for the entire SmartTarget. When concurrent dials for one target complete through different proxies, each later success closes connections established by earlier successes. Selection therefore becomes latest-success-wins churn: Smart rapidly rotates active traffic instead of maintaining stable learned routing. Long-lived TCP and UDP sessions are destroyed without any quality failure, surfacing as TLS unexpected EOF and causing browsers to retry or move traffic to QUIC. Remove the non-forced cleanup from successful TCP and UDP dials. Keep forced cleanup in the measured degradation path so Smart can still evict connections backed by actual failure evidence.
qoli
force-pushed
the
codex/preserve-smart-connections
branch
from
September 1, 2026 07:51
5185f6e to
efe02b9
Compare
vernesong
added a commit
that referenced
this pull request
Sep 4, 2026
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.
Severity: this breaks the Smart selection model
This is not merely connection cleanup. It turns Smart from a quality-learning, continuity-preserving selector into a latest-success-wins connection rotator.
Smart stores an unwrap result so later connections to the same
SmartTargetcan reuse the learned selection. But every successful TCP or UDP dial also callscloseSameConnection(..., false). Any active connection for that target using a different proxy is closed even though no degradation was observed.Normal web pages create many concurrent connections. If those dials complete through different candidates, every later completion invalidates earlier successful traffic:
This self-induced churn destroys Smart connection continuity and makes it behave like rapid proxy rotation rather than stable learned selection. It applies to every concurrent Smart target, not only Pinterest. Symptoms include TLS
unexpected EOF, interrupted transfers, reconnect storms, and browsers shifting toward QUIC after TCP is repeatedly destroyed.Reproduction
On an isolated iStoreOS 24.10.8 x86_64 router, 15 concurrent Pinterest HTTPS requests produced:
unexpected EOF, 1 timeoutThese controls separate node quality from Smart-generated churn.
Change
Remove success-path sibling cleanup for TCP and UDP. Smart still stores unwrap results and records metrics. Forced cleanup remains unchanged:
closeSameConnection(..., true)runs only after measured degradation or host-failure evidence.Verification
With the same Smart configuration and pool, four bursts totaling 60 Pinterest requests produced:
unexpected EOFThe final burst had 15 matching controller TCP logs. The same code was then deployed on ARM64 OpenWrt: Smart remained loaded, takeover stayed effective, and a five-request live check completed 5/5 with HTTP 200 and no EOF.
Tests
go test ./adapter/outboundgroup ./component/smart ./tunnel/statisticgo test ./...git diff --check