group: Fix interrupt_exist_connections for routed connections - #4285
Open
xxspa wants to merge 162 commits into
Open
group: Fix interrupt_exist_connections for routed connections#4285xxspa wants to merge 162 commits into
xxspa wants to merge 162 commits into
Conversation
`SecTrustEvaluateWithError` is serial
This reverts commit 62cb06c.
nekohasekai
force-pushed
the
testing
branch
18 times, most recently
from
July 23, 2026 13:08
41f736e to
5d744ad
Compare
nekohasekai
force-pushed
the
testing
branch
12 times, most recently
from
July 28, 2026 01:07
fcd1c18 to
3429352
Compare
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.
Fixes #4281.
Root cause
Connections routed to a selector (as a route target or
route.final) enter through theConnectionHandlerpath (Selector.NewConnection/NewPacketConnection). Neither branch of that path goes throughSelector.DialContext/ListenPacket, so these connections were never registered in the selector's interrupt group.SelectOutboundthen interrupted an empty set, and existing connections kept flowing over the previously selected outbound — makinginterrupt_exist_connectionsa near no-op for user traffic.URLTest is not affected on this path because its
NewConnectionpasses itself as the dialer, so dialing goes throughURLTest.DialContext, which registers the connection.Fix
NewConnection/NewPacketConnection, covering both the nested-handler branch and the connection-manager branch. Simply passing the selector as the dialer (URLTest-style) would not be enough: members that only implementConnectionHandler(e.g. the dns outbound) need the handler branch, and connections handled by nested group members are only registered in the inner group.SingPacketConn/Group.NewSingPacketConntocommon/interruptso anN.PacketConncan be registered, mirroring the existing wrappers (withUpstream/ReaderReplaceable/WriterReplaceablepass-through).Tests
New end-to-end tests in
test/group_test.go(full box instance, SOCKS inbound, selector asroute.final, direct members, local echo servers):TestSelectorInterruptRoutedConnection: an established TCP connection must be closed afterSelectOutboundwheninterrupt_exist_connectionsis enabled — failed before this fix (read timed out), passes now.TestSelectorInterruptRoutedPacketConnection: a UDP session must be re-established over a new outbound socket after switching — failed before this fix (same source observed by the echo server), passes now.TestSelectorKeepRoutedConnection: withinterrupt_exist_connectionsdisabled, existing connections must survive switching — passes before and after, guarding the default semantics.Note: the test module's
go.mod/go.sumare currently behind the main module (missing entries forsing-tun/gtcpip/checksumimported bycommon/tlsspoof), so running the tests requires ago mod tidyintest/first; that sync is intentionally not included in this PR.