Repository navigation
Socks inbound: Fix stats for UDP Associate traffic - #7101
Merged
Merged
Conversation
patterniha
pushed a commit
to patterniha/Xray-core
that referenced
this pull request
Oct 8, 2026
Early merge of XTLS#7101 (PR head 1c93878), squashed, ahead of it landing upstream: XTLS#7101 Co-authored-by: 风扇滑翔翼 <[email protected]>
fanymagnet
pushed a commit
to fanymagnet/Xray-core
that referenced
this pull request
Oct 8, 2026
XTLS#7101 (review) --------- Co-authored-by: 风扇滑翔翼 <[email protected]>
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.
SOCKS5 UDP ASSOCIATE creates a temporary UDP connection that bypasses the inbound
stat.CounterConnection. UDP forwarding works, but inbound traffic statistics count only the TCP control handshake.For a 1200-byte UDP request and a 700-byte response, the unpatched counters remain at 13/12 bytes. Including the SOCKS UDP headers, they should reach 1223/722 bytes.
Reuse the control connection's existing read/write counters when handling the temporary UDP connection. This preserves disabled statistics and the existing UDP source filtering and connection lifetime.
The regression test covers enabled/disabled inbound statistics, two UDP exchanges, exact byte counts, and rejection of a datagram from an unrelated source. It fails on current
mainwithout the fix and passes with it.Validation:
go test ./proxy/socks -count=20go test -race ./proxy/socks -count=1go run ./infra/vformat/main.go -mode check -pwd ./