mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6344] [MERGED] fix: preserve per-inbound WireGuard peer addresses #6226
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#6226
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/6344
Author: @mvanhorn
Created: 8/28/2026
Status: ✅ Merged
Merged: 9/2/2026
Merged by: @MHSanaei
Base:
main← Head:fix/6328-preserve-wireguard-peer-addresses📝 Commits (1)
b455706fix: preserve per-inbound WireGuard peer addresses📊 Changes
2 files changed (+100 additions, -0 deletions)
View changed files
📝
internal/web/service/xray.go(+14 -0)📝
internal/web/service/xray_wireguard_config_test.go(+86 -0)📄 Description
Summary
WireGuard peers were built from the shared per-email client record, so a client present on both a WireGuard and an AmneziaWG inbound got one tunnel's
allowedIPsandpreSharedKeyon both. This reads the per-inbound client settings and uses the inbound's own entry when one exists for that email.Why
Closes #6328
Clients are stored once per email in the client table.
GetXrayConfigbuilt each WireGuard peer from that shared record, so the per-inbound values were lost whenever the same email appeared on two WireGuard-family inbounds. The second tunnel's peer was then emitted with the first tunnel's address, which breaks routing for that client.The inbound already carries its own client settings; they were simply not consulted on the WireGuard path.
Type of change
Areas affected
How was this tested?
Added
TestGetXrayConfigWireGuardUsesInboundLocalTunnelFields, which seeds one email on both a WG inbound (10.0.0.5/32,wg-psk) and an AWG inbound (10.8.1.5/32,awg-psk) and asserts each inbound's peer keeps its own address and pre-shared key.The test pins the bug rather than merely covering the path. Reverting only
internal/web/service/xray.goand keeping the test:That is the reported symptom exactly: the AWG tunnel's address on the WG peer.
Not tested: no run against a live Xray instance with two active tunnels. The assertion is on generated config, not on observed traffic.
Screenshots / recordings
N/A. Backend config generation, no UI change.
Breaking changes
None. Behaviour only changes where an inbound carries its own client entry for that email; when it does not, the existing shared-record values are used exactly as before.
Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass.Frontend checks are unchecked because there are no frontend changes. Docs are unchecked because the corrected behaviour is what the panel already documents; nothing user-facing changed.
AI assistance disclosure
internal/web/service/xray.goandinternal/web/service/xray_wireguard_config_test.goonly.AI was used for assistance.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.