mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6328] [Bug]: AmneziaWG together with WireGuard for the same client invokes WG doesn't work #4298
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#4298
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 @Erapchu on GitHub (Aug 25, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6328
Describe the bug
I'm expecting WG and AWG can work together for the same client
How to reproduce the problem
Create inbound AWG
Create inbound WG
Setup client to use WG
Save
Try use WG -- that works
Setup client to use AWG
Save
Try use WG -- it doesn't work anymore. Also I can't find some WG options in client's popup.
Expected behavior
WG works together with AWG
Actual behavior
WG doesn't work when AWG configured. AWG works as expected.
Relevant logs
Screenshots
Only AWG configured:

AWG + WG:
Only WG:
3x-ui version
3.7.0
Xray-core version
26.7.28
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu 24.04.4
Which parts of the panel are affected?
Other
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
No response
Before submitting
@github-actions[bot] commented on GitHub (Aug 25, 2026):
Confirmed bug, and it is not a conflict between the two protocols on the wire: your client identity has one WireGuard address column in the database, attaching it to the AmneziaWG inbound overwrites it, and the panel then rebuilds the WireGuard inbound's peer list from that overwritten value.
What actually happens
1. The panel deliberately gives the identity a different address on each tunnel inbound. WireGuard's default subnet is
10.0.0.0/24(internal/web/service/client_wireguard.go:15,const defaultWireguardBase = "10.0.0.0/24") and AmneziaWG's is10.8.1.0/24(frontend/src/schemas/protocols/inbound/amneziawg.ts:54,subnetIp: z.string().default('10.8.1.0')). So when you attach an identity that already holds a WireGuard address to an AmneziaWG inbound, the inherited address is cleared and a fresh in-subnet one is allocated:2. Persisting that new AmneziaWG peer writes its address into the shared client row.
model.ClientRecordhas exactly one column for it —internal/database/model/model.go:928:and every per-inbound persist funnels through the same merge (
internal/web/service/client_link.go:51):After the AmneziaWG save,
clients.wg_allowed_ipsfor your email is the AmneziaWG address (e.g.10.8.1.2/32).3. The WireGuard inbound's
peers[]is regenerated from that shared row, not from the WireGuard inbound's own settings JSON —internal/web/service/xray.go:183and:246:ListForInboundselectsclients.*(internal/web/service/client_link.go:307-312),ClientRecord.ToClientmaps that single column straight into the peer (internal/database/model/model.go:1200,AllowedIPs: splitWireguardAllowedIPs(r.AllowedIPs)), andWireguardPeerFromClientemits it verbatim (internal/database/model/model.go:438-439,peer["allowedIPs"] = c.AllowedIPs).Net effect: the WireGuard inbound's peer for your email now carries
10.8.1.x/32while your WireGuard client still sources packets from10.0.0.x, so xray-core's WireGuard inbound drops them. AmneziaWG keeps working because its peers are derived from the inbound's own settings JSON, never from the clients table (internal/amneziawg/instance.go:27-46). Saving an AmneziaWG inbound also forces a full Xray restart rather than a hot swap (internal/xray/hot_diff.go:164-165), which is why it breaks the moment you press Save instead of at the next restart.Check it on your server
If the
allowedIPsprinted there sits in your AmneziaWG subnet instead of your WireGuard one, that is this bug. (I cannot run the panel here, so this is the one thing worth confirming from your side.)Workaround until it is fixed
Give the device two separate client identities — two different emails, one attached to the WireGuard inbound and one to the AmneziaWG inbound. Each gets its own
clientsrow, so neither can overwrite the other's address. Attaching a single identity to both tunnel protocols is what triggers the overwrite.The missing options in the client popup
That part is cosmetic and separate. When both a WireGuard and an AmneziaWG inbound are attached, the private key / public key / pre-shared key inputs get relabelled with the AmneziaWG strings even though they are the same shared fields —
frontend/src/pages/clients/ClientFormModal.tsx:1194-1237, e.g.showAmneziawg ? 'pages.clients.amneziaWgPrivateKey' : 'pages.clients.wireguardPrivateKey'. The AllowedIPs input does correctly split into two separately labelled fields in that case (ClientFormModal.tsx:1240-1257). Nothing is removed; the labels just stop saying "WireGuard".Verdict: Confirmed bug
Severity: High
Confidence: High
Root cause:
XrayService.GetXrayConfigbuilds a WireGuard inbound'speers[]from the sharedclientsrow instead of that inbound's own settings JSON —internal/web/service/xray.go:183(ListForInbound, which selectsclients.*) feedinginternal/web/service/xray.go:246-247(model.WireguardPeerFromClient).model.ClientRecordhas a singlewg_allowed_ipscolumn (internal/database/model/model.go:928), andapplyClientRecordMerge(internal/web/service/client_link.go:51-52) lets the last tunnel inbound persisted win it. Triggering condition: one client identity attached to both awireguardand anamneziawginbound, which by design hold addresses in different subnets. Reachable sinceeffccccefeat(amneziawg): add native AmneziaWG protocol support (#6105), the commit that introducedmodel.AmneziaWGas a second protocol sharing the WireGuard client columns; theListForInbound-based peer generation itself is older.Already fixed: Still present on the default branch (tip
f727d04f,v3.7.0— the same version reported).Duplicate of: None. Related: #5785 (address duplication across two WireGuard inbounds) — same table, different root cause (allocation collision, addressed by the
crossInboundUsed/otherTunnelAllowedIPspath ininternal/web/service/client_inbound_apply.go:253), so not a duplicate.Evidence:
internal/web/service/xray.go:183dbClients, listErr := s.inboundService.clientService.ListForInbound(nil, inbound.Id);internal/web/service/xray.go:246-247case model.WireGuard: wgPeers = append(wgPeers, model.WireguardPeerFromClient(c));internal/web/service/client_link.go:307-312tx.Table("clients").Select("clients.*, client_inbounds.flow_override AS flow_override");internal/database/model/model.go:928AllowedIPs string \gorm:"column:wg_allowed_ips"`;internal/database/model/model.go:1200AllowedIPs: splitWireguardAllowedIPs(r.AllowedIPs);internal/database/model/model.go:438-439peer["allowedIPs"] = c.AllowedIPs;internal/web/service/client_link.go:51-52the guarded overwrite;internal/web/service/client_crud.go:839-840the Attach-side clear that guarantees the two addresses differ;internal/amneziawg/instance.go:27-46the AmneziaWG side reading the inbound settings instead. Intent evidence that per-inbound addresses are the design, not the record column:model.Client.AllowedIPsByInbound(internal/database/model/model.go:884-891),ClientService.TunnelAllowedIPsByInbound(internal/web/service/client_lookup.go:136-143, "ClientRecord's own single AllowedIPs column can't tell two different protocol addresses apart"), andTestUpdateBroadcastAllowedIPsDoesNotOverwriteOtherInboundWhenMismatched/TestUpdateAllowedIPsByInboundAppliesDistinctValuesPerInbound(internal/web/service/client_update_allowedips_test.go:60,:84) — both assert only on the inbounds' settings JSON viainboundAllowedIPs, never on the generated Xray config, which is exactly the gap.internal/web/service/xray_wireguard_config_test.gocovers WireGuard peer emission but only for single-inbound clients. Not determined: Whether the reporter's AmneziaWG inbound uses the default10.8.1.0/24subnet. If they had manually set it to the same subnet as the WireGuard inbound, the overwritten value could coincidentally still be routable. Thejqcommand above settles it. Suggested fix: Make the WireGuard branch ofGetXrayConfigread each peer'sallowedIPs(and pre-shared key) from the WireGuard inbound's own settings JSON, the way the liveGenXrayInboundConfigpath already does viamodel.WireguardClientsToPeers, instead of from the sharedclientsrow. A regression test ininternal/web/service/xray_wireguard_config_test.goseeding the existingseedDualProtocolClienthelper and asserting the emittedpeers[].allowedIPs` would pin it.@MHSanaei
This reply was generated automatically; a maintainer may follow up.
@Ramazik commented on GitHub (Aug 26, 2026):
I can confirm the error and the screenshots. AmneziaWG isn't working for me. I already had a WireGuard inbound configuration set up prior to the update. I tried disabling the WireGuard inbound configuration and removing the WireGuard subscription from the user profile. I tried various combinations of these steps, but I couldn't get AmneziaWG to work with the AmneziaVPN app (version v5.0.1.5), which supports protocol v3.1.
@Erapchu commented on GitHub (Aug 26, 2026):
Don't use AmneziaVPN to connect to AmneziaWG published via 3X-UI. Use AmneziaWG native app (almost same as WireGuard native app) on smart-phones or PC.
@Ramazik commented on GitHub (Aug 26, 2026):
I use both apps. Updates adding support for the v3.1 protocol were released simultaneously for both AmneziaVPN and AmneziaWG, though I noticed the update for the latter later.
Just an update: the AWG protocol is working now (but the speed is very low, around 2.5 megabits).
The issue was an incompatibility with the running "zapret" application by bol-van. It’s a weird situation—apparently, it’s incompatible with protocol version 3.1, even though I never had to disable zapret with other AWG connections using earlier protocol versions.