mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
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#4487
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?
Originally created by @unger2007-beep on GitHub (Oct 4, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6731
Describe the bug
A client attached to both a WireGuard inbound and an AmneziaWG inbound gets a WireGuard peer in the generated Xray config with the AmneziaWG identity's public key. The subscription (after #6653) correctly hands the client the WireGuard inbound's own private key, so the two never match: the WireGuard handshake never completes. AmneziaWG keeps working.
This looks like the unfinished half of #6328. Its fix overlays the inbound's own
AllowedIPsandPreSharedKeyonto the sharedclientsrow, but notPublicKey:ccomes fromListForInbound(the sharedclientsrow), whose key columns hold whichever tunnel inbound was synced last — here the AmneziaWG one. On v3.8.5 the mismatch appeared in the subscription instead (#6641). Since #6653 the subscription reads per-inbound identity, so the Xray config is now the inconsistent side, and it is wrong every time.How to reproduce the problem
Fresh
ghcr.io/mhsanaei/3x-ui:v3.9.0container, API token fromx-ui setting -getApiToken:address: ["10.1.0.1/24"]).10.9.1.0/24).POST /panel/api/clients/add{"client":{"email":"carol","subId":"carolsub","enable":true},"inboundIds":[<wg>,<awg>]}/sub/carolsub,wireguard://<privkey>@…) with the peer the panel wrote for Xray:jq '.inbounds[] | select(.protocol=="wireguard") | .settings.peers' /app/bin/config.jsonExpected behavior
The Xray WireGuard peer for
carolcarries the WireGuard inbound's own public key, the one matching the private key in her WireGuard link and in the inbound's settings.Actual behavior
v3.9.0, one run (public keys,
xray wg -i <privkey>for link keys):EJcNa+/36dh…10.0.0.2/32/panel/api/inbounds/list)EJcNa+/36dh…10.0.0.2/32bin/config.json)g7TRyaDMyjG…10.0.0.2/32g7TRyaDMyjG…10.9.1.2/32The WireGuard peer has the right address (fixed by #6328) but the AmneziaWG key. The client's handshake initiations go unanswered. Xray client debug log:
Handshake did not complete after 5 seconds, retrying.The same happens for inbounds pushed to a multi-node node; it is the same code path on the node. A client attached to the WireGuard inbound only passes traffic normally on the same inbound.
Relevant logs
Screenshots
No response
3x-ui version
v3.9.0 (the WireGuard branch above is unchanged on
mainas of 2026-10-04)Xray-core version
26.9.30
How did you install 3x-ui?
Docker / Docker Compose
Operating system
Docker Engine 29 on Ubuntu 24.04
Which parts of the panel are affected?
Xray config generation
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
No — direct access
Suggested fix
In
GetXrayConfig's WireGuard branch, also takePublicKey(andKeepAlive) from the inbound's own settings entry, the same tunnel-identity set #6653 overlays for subscriptions. The workaround until then is one client (email) per tunnel inbound.Related: #6328, #6641, #6653.
Before submitting
@github-actions[bot] commented on GitHub (Oct 4, 2026):
You're right: this is a real bug and it is still on the default branch. When
GetXrayConfigbuilds a WireGuard peer, it copiesAllowedIPsandPreSharedKeyfrom the inbound's own settings entry but takesPublicKeyandKeepAlivefrom the sharedclientsrow. That row holds the tunnel identity of whichever WireGuard/AmneziaWG inbound was synced last.How it happens
ListForInboundreadsclients.*joined throughclient_inbounds(internal/web/service/client_link.go:369-372). That gives one row per client, and its key lives in a single column:PublicKey string ... gorm:"column:wg_public_key"(internal/database/model/model.go:930).GetXrayConfigparses the inbound's own settings intowireguardClientsByEmail(internal/web/service/xray.go:211-220). It then overlays only part of that entry:WireguardPeerFromClientwritespeer["publicKey"] = c.PublicKeyandkeepAlivefromc.KeepAliveSeconds()(internal/database/model/model.go:437-448). Those values come from the shared row, not from this inbound.The commit message of #6653 (
0dec3d65) describes the same shared row: "the shared clients rows, whose wg_* columns hold whichever WireGuard/AmneziaWG inbound synced last". That fix only touchedinternal/sub/service.go, whereoverlayInboundTunnelIdentitynow copiesPrivateKey,PublicKey,PreSharedKey,AllowedIPsandKeepAlive. The Xray-config side still copies only two of those fields. That explains your table: the address is correct (from the #6344 overlay) and the key is the AmneziaWG one.The live gRPC path does read the right key.
WireguardClientsToPeers(internal/database/model/model.go:464-493) builds peers straight from the inbound's settingsclients. So right after an inbound add or edit the running peer may be correct, and it goes wrong on the next full config generation (restart,config.jsonwrite). I worked that out from the code and did not run it.Your workaround holds until a fix lands: use one client (email) per WireGuard/AmneziaWG inbound.
Verdict: Confirmed bug
Severity: Medium (only a client attached to two or more WireGuard/AmneziaWG inbounds on the same panel, but for that client the WireGuard handshake fails every time)
Confidence: High
Root cause:
internal/web/service/xray.go:286-289(XrayService.GetXrayConfig, WireGuard branch) copies onlyAllowedIPs/PreSharedKeyfrom the inbound's settings entry.PublicKey/KeepAlivestay as the sharedclients.wg_*values, which belong to the last-synced tunnel inbound. The partial overlay came fromf6445304"fix: preserve per-inbound WireGuard peer addresses (#6344)".Already fixed: No. Still present on the default branch (
815c9c57) and in v3.9.0.Duplicate of: None. Related: #6328 (address half, fixed by
f6445304), #6641 / #6653 (0dec3d65, the same shared-row problem fixed for subscriptions only)Evidence:
internal/web/service/xray.go:285-290;internal/database/model/model.go:435-449(WireguardPeerFromClient),:930(wg_public_keycolumn);internal/web/service/client_link.go:360-386(ListForInboundreturnsclients.*);internal/sub/service.gooverlayInboundTunnelIdentityfrom0dec3d65(the full overlay done for subscriptions).Not determined: Whether a multi-node node can reach this with a client on only one inbound there. It depends on the node's local
clientsrow, and testing a node holding a single tunnel inbound would settle it. Inferred from the code: two plain WireGuard inbounds sharing one client should fail the same way, because the shared row only ever holds one key.Suggested fix: In
GetXrayConfig's WireGuard branch, take the whole tunnel identity (PublicKey,PreSharedKey,AllowedIPs,KeepAlive) from this inbound's settings entry, the same setoverlayInboundTunnelIdentitycopies for subscriptions. A test with one client on two tunnel inbounds that have different keys, asserting each peer'spublicKey, would pin it.This reply was generated automatically; a maintainer may follow up.
@mvanhorn commented on GitHub (Oct 6, 2026):
GetXrayConfig builds the WireGuard peer from the shared clients row and only overwrites AllowedIPs and PreSharedKey from the inbound settings entry for that email. PublicKey and KeepAlive stay as stored on the shared row, which holds the tunnel identity of whichever WireGuard or AmneziaWG inbound was synced last, and WireguardPeerFromClient emits those leftover fields.
The WireGuard branch now copies PublicKey from the matching inbound settings client. When that entry's KeepAlive is nil the peer keepalive is cleared, and when it is set the integer is copied into a new pointer.