mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #6320] [MERGED] feat(amneziawg): add AmneziaWG as an outbound protocol #6218
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#6218
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/6320
Author: @rqzbeh
Created: 8/25/2026
Status: ✅ Merged
Merged: 9/10/2026
Merged by: @MHSanaei
Base:
main← Head:feat/amneziawg-outbound-v2📝 Commits (9)
43be40cfeat(amneziawg): add AmneziaWG as an outbound protocolb6df3f6Merge branch 'main' into feat/amneziawg-outbound-v2458499afix(amneziawg): resolve IPv6-only DNS default fallback and validate required keysb79e2f9Merge branch 'main' into feat/amneziawg-outbound-v2c259a19Merge remote-tracking branch 'upstream/main' into feat/amneziawg-outbound-v25973f41Merge remote-tracking branch 'origin/feat/amneziawg-outbound-v2' into feat/amneziawg-outbound-v215b8494Merge branch 'main' into feat/amneziawg-outbound-v24ac2fd3Merge branch 'main' into feat/amneziawg-outbound-v247f29b6Merge branch 'main' into feat/amneziawg-outbound-v2📊 Changes
50 files changed (+4169 additions, -33 deletions)
View changed files
📝
docs/architecture.md(+27 -0)📝
frontend/.storybook/preview-head.html(+3 -0)📝
frontend/src/hooks/useXraySetting.ts(+8 -1)📝
frontend/src/lib/xray/outbound-form-adapter.ts(+106 -0)📝
frontend/src/pages/xray/outbounds/OutboundFormModal.tsx(+2 -0)➕
frontend/src/pages/xray/outbounds/protocols/amneziawg.tsx(+228 -0)📝
frontend/src/pages/xray/outbounds/protocols/index.ts(+1 -0)📝
frontend/src/schemas/forms/outbound-form.ts(+7 -0)📝
frontend/src/schemas/primitives/outbound-protocol.ts(+1 -0)➕
frontend/src/schemas/protocols/outbound/amneziawg.ts(+49 -0)📝
frontend/src/schemas/protocols/outbound/index.ts(+3 -0)➕
frontend/src/test/amneziawg-outbound-adapter.test.ts(+95 -0)➕
internal/amneziawg/outbound.go(+323 -0)➕
internal/amneziawg/outbound_test.go(+312 -0)➕
internal/amneziawgnet/client_device.go(+139 -0)➕
internal/amneziawgnet/client_device_test.go(+117 -0)📝
internal/amneziawgnet/device.go(+9 -3)➕
internal/amneziawgnet/dns.go(+216 -0)➕
internal/amneziawgnet/egress.go(+652 -0)➕
internal/amneziawgnet/egress_domain_test.go(+741 -0)...and 30 more files
📄 Description
Summary
Adds AmneziaWG (AWG) as an outbound option — the outbound counterpart of the embedded AmneziaWG inbound support. An admin can declare an
amneziawgoutbound in the Xray settings; the panel runs an amneziawg-go client device for it and routes Xray's traffic through that tunnel.Supersedes #6309 (same feature, one squashed commit, all review findings fixed).
Why
Closes #6302. Hardened cascading panel-to-panel tunnels need AmneziaWG on the egress side; today AWG is inbound-only (#6105), and hanging the obfuscation fields off the stock WireGuard outbound cannot work because Xray-core has no AWG proxy — outbound JSON is handed to the core verbatim.
The design mirrors the inbound engine one-for-one: an embedded amneziawg-go device over a gVisor netstack inside the panel process (no kernel module, nothing new to install). The generated config swaps each
amneziawgoutbound to a loopback SOCKS5 bridge pointed at the panel's own egress server, which dials into that outbound's device.Review fixes baked in
Every finding from the #6309 review is fixed here, with tests:
address/port/user/pass(addris not a key xray-core understands; nilAddressrefuses the whole generated config)persistent_keepalive_interval, not_seconds(unknown keys makeIpcSethard-error, so peers never installed); exact emitted line pinned by a table testhmac.Equalagainst the process-wide secret instead of being read and discardedgonet.DialUDPendpoints with stack-assigned source ports + reply pump wrapping responses in SOCKS5 UDP headers; associated client's source address pinned per RFC 1928ln.Close(), accepted conns tracked and closed onClose()(no hang on healthy flows),Listenre-arms its own channelStopAllderegister from the egress server, so closed devices are never served\nsilently truncates IpcSet's peer set);i1–i5passValidateConfigValueForm.Item extrainstead of inert Tailwind utility classesHow was this tested?
Backend:
internal/amneziawgnet/client_device_test.go: UAPI keepalive key asserted exactly (fails without the fix — verified by temporary revert)internal/amneziawg/outbound_test.go: newline-in-allowedIPs rejected at validation, normalized at parse boundary, unparseable entries rejected, i1–i5 control-char matrixxray_amneziawg_outbound_test.go: assertsaddresskey + non-empty passwordgo test -shuffle=on -count=1 ./internal/...green locally (one pre-existing flake inTestAcquireUpdateSlotConcurrencyreproduced on a clean tree too) and targeted suites green on a second machine (Go 1.27 linux/amd64)go test -race ./internal/amneziawgnet/...clean;go vetcleanFrontend:
Type of change
Areas affected
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.