mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6410] [Bug]: AmneziaWG is not handled correctly in JSON subscription #4341
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#4341
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 @barbod1123-bit on GitHub (Sep 4, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6410
Describe the bug
After AmneziaWG support was added in 3X-UI 3.7.0, AmneziaWG nodes are included in the subscription when using the JSON format.
How to reproduce the problem
However, AmneziaWG does not support the JSON subscription format currently generated by 3X-UI. As a result, the generated JSON subscription is not compatible with AmneziaWG clients.
Expected behavior
The subscription system should properly handle AmneziaWG configurations, or exclude AmneziaWG nodes when the selected subscription format is incompatible with this protocol.
Actual behavior
No response
Relevant logs
Screenshots
No response
3x-ui version
3.7.0
Xray-core version
No response
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu 22
Which parts of the panel are affected?
No response
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
None
Before submitting
@github-actions[bot] commented on GitHub (Sep 4, 2026):
Confirmed — this is a real bug, and it is still present on the default branch. An AmneziaWG inbound is selected for a JSON subscription, but
SubJsonService.getConfighas no branch for it, so the entry it emits contains no proxy outbound at all.Where it goes wrong
The inbound is deliberately included in the subscription query — the protocol is in the allowlist:
The raw
/sub/body then builds a correct link for it (internal/sub/service.go:645-646→genAmneziaWGLink, which returns"vpn://" + base64.RawURLEncoding.EncodeToString([]byte(text)),internal/sub/service.go:820).The JSON generator does not. Its protocol switch stops at
wireguard:amneziawgmatches no case. Unlike thewireguardcase there is nocontinue, so execution falls straight through toand the entry is appended to the array at
internal/sub/json_service.go:603. The default outbounds are onlydirect(freedom) andblock(blackhole) (internal/sub/default.json:45-63), while the routing rule copied into every entry sends all traffic to a tag that is now absent:So each AmneziaWG client gets a named, non-functional entry in
/json/. For comparison, the Clash generator handles the same gap by dropping the proxy instead of emitting a broken one (default: return nil,internal/sub/clash_service.go:294-295) — that omission is tracked separately as #6310.Your second suggestion is the realistic one: AmneziaWG is not an Xray outbound protocol in this panel at all — it runs in-process over a userspace netstack (
internal/amneziawgnet/, seeinternal/xray/hot_diff.go:302-303), so an Xray JSON config has no field that can carry the tunnel or its obfuscation parameters.Workaround
Use the raw subscription (
/sub/…) rather than the JSON one for AmneziaWG clients, or export the client from the panel directly — both already produce a valid payload (avpn://…link or the.conftext) that the AmneziaVPN/AmneziaWG app imports. See Configuration → AmneziaWG.Verdict: Confirmed bug
Severity: Medium
Confidence: High
Root cause:
SubJsonService.getConfig,internal/sub/json_service.go:568-592— theswitch inbound.Protocolhas noamneziawgcase (normtproto), and, unlike thewireguardcase at:586-591, nothing skips the entry, so control reachesnewOutbounds = append(newOutbounds, s.defaultOutbounds...)at:594and a config whose only outbounds aredirectandblockis appended at:603. Triggering condition: any enabledamneziawginbound with a client carrying the requestedsubId, fetched through the JSON subscription format. Introduced byeffcccce"feat(amneziawg): add native AmneziaWG protocol support (#6105)", which added'amneziawg'to thegetInboundsBySubIdallowlist (internal/sub/service.go:494) and toGetLink(internal/sub/service.go:645) but not to the JSON or Clash generators.Already fixed: Still present on the default branch (
3ef06b70, after v3.7.0). The equivalent defect for native WireGuard was fixed ind2efe9b0"fix(sub): include native WireGuard clients in Clash and JSON subscriptions (#5676)" — that commit added exactly the branch AmneziaWG is still missing.Duplicate of: None. Related: #6310 covers the same feature gap in the Clash generator; the open PR for it, #6326, changes only
internal/sub/clash_service.goandinternal/sub/clash_service_test.go, so it does not touch this path.mtprotohits the identical fall-through in the sameswitch.Evidence:
internal/sub/service.go:494(allowlist includes'amneziawg');internal/sub/service.go:645-646and:820(raw link works,vpn://+ base64url);internal/sub/json_service.go:568-592(switch with noamneziawgcase),:586-591(thecontinuethe WireGuard case has),:594(s.defaultOutbounds...),:603(entry appended);internal/sub/default.json:45-63(direct/blockonly) and:85("outboundTag": "proxy");internal/sub/clash_service.go:294-295(default: return nil— the other generator skips instead);TestGetInboundsBySubIdIncludesAmneziaWG(internal/sub/service_amneziawg_test.go:165-189) pins only the DB selection, andinternal/sub/json_service_test.gocontains no AmneziaWG case — nothing asserts the current output as intended.Not determined: Whether a client fed this entry errors out or silently routes the traffic direct through the
directfreedom outbound (the routing rule targets a tag that does not exist in the config). I cannot run Xray here; reading xray-core's router fallback for an unresolvableoutboundTagsettles it, and it decides whether this is a dead entry or a leak.Suggested fix: In
getConfig, giveamneziawg(andmtproto) an explicitcontinuealongside thewireguardcase, so the JSON format skips a protocol it cannot express instead of emitting a proxy-less config — matching whatinternal/sub/clash_service.go:294-295already does. A test ininternal/sub/json_service_test.goasserting that an AmneziaWG-onlysubIdyields an empty JSON array would pin it.This reply was generated automatically; a maintainer may follow up.
@barbod1123-bit commented on GitHub (Sep 4, 2026):
To clarify my suggestion: I don't mean adding AmneziaWG as an Xray outbound.
I mean having one JSON subscription URL containing all protocols, while each protocol uses its own configuration format inside the JSON.
For example, Xray protocols (VLESS, VMess, Trojan, etc.) would use their normal Xray configuration structure, while AmneziaWG would have a separate/custom structure containing its own parameters.
This would allow a compatible client to parse each entry based on its "type" and handle AmneziaWG independently from Xray.
So the goal is a unified JSON subscription, not forcing AmneziaWG into the Xray outbound format.