-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Fix WireGuard multi-peer outbound: responses routed to wrong endpoint #5554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Copilot
wants to merge
3
commits into
main
Choose a base branch
from
copilot/fix-xray-core-issue-4507
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+52
−37
Conversation
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
Member
Member
|
@Fangliding 3.5 sonnet 和 4.5 opus 都说是 readQueue 的问题, |
Member
|
确实是这个问题 |
In the original implementation, all peer connections shared a single readQueue channel where ReceiveFunc workers would request buffers. This caused responses from different peers to be incorrectly associated with the wrong endpoint when multiple peers were active. The fix changes to a push-based architecture where: - Each endpoint's read goroutine pushes responses directly to a shared responseRecv channel along with the correct endpoint identity - The ReceiveFunc workers simply receive from this channel - This ensures each response is correctly associated with its source endpoint Fixes issue #4507: multi wg peers outbound only one established Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
Member
|
@Fangliding 那你看一下它代码写得有没有问题吧 |
Member
|
这个应该不太对 我也不知道我想的是不是对的 不过主要是复现这个确实有点麻烦 |
Copilot
AI
changed the title
[WIP] Fix underlying issue in Xray-core as per issue #4507
Fix WireGuard multi-peer outbound: responses routed to wrong endpoint
Jan 16, 2026
Member
|
@Fangliding
|
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.
When multiple WireGuard peers are configured in an outbound, only the first established peer works. Subsequent peer connections fail with "Received invalid response message" because responses are incorrectly associated with the wrong endpoint.
Root Cause
All peer connections shared a single
readQueuechannel. Each peer'sconnectTo()spawned a goroutine reading from this shared queue, causing race conditions where responses from peer B could be attributed to peer A's endpoint.Changes
Architecture: Changed from pull-based (receiver requests buffer, sender fills) to push-based (sender pushes data with endpoint identity)
{data, endpoint}tuples to sharedresponseRecvchannelReceiveFuncsimply receives from this channel with correct endpoint associationMemory: Added
sync.Poolfor buffer reuse to reduce GC pressureOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.