[PR #6309] [CLOSED] feat(amneziawg): add AmneziaWG as an outbound protocol #6215

Closed
opened 2026-11-02 04:07:09 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6309
Author: @rqzbeh
Created: 8/25/2026
Status: ❌ Closed

Base: main ← Head: feat/amneziawg-outbound


📝 Commits (1)

  • beb8cb7 feat(amneziawg): add AmneziaWG as an outbound protocol

📊 Changes

34 files changed (+2005 additions, -15 deletions)

View changed files

📝 frontend/src/lib/xray/outbound-form-adapter.ts (+104 -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 (+89 -0)
➕ internal/amneziawg/outbound.go (+273 -0)
➕ internal/amneziawg/outbound_test.go (+201 -0)
➕ internal/amneziawgnet/client_device.go (+145 -0)
📝 internal/amneziawgnet/device.go (+11 -1)
➕ internal/amneziawgnet/egress.go (+386 -0)
➕ internal/amneziawgnet/outbound_manager.go (+170 -0)
📝 internal/web/job/amneziawg_job.go (+59 -0)
📝 internal/web/service/xray.go (+4 -0)
➕ internal/web/service/xray_amneziawg_outbound.go (+66 -0)
➕ internal/web/service/xray_amneziawg_outbound_test.go (+138 -0)
📝 internal/web/service/xray_setting.go (+14 -0)

...and 14 more files

📄 Description

Summary

Adds AmneziaWG (AWG) as an outbound option, the outbound counterpart of the existing embedded AmneziaWG inbound support. An admin can now declare an amneziawg outbound in the Xray settings; the panel runs an amneziawg-go client device for it and routes Xray's traffic through that tunnel.

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).

Type of change

  • New feature
  • Bug fix
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

Backend (go test ./... — 41 packages green):

  • New internal/amneziawg/outbound_test.go: instance derivation + validation accept/reject matrix (bad endpoints, control chars, empty allowedIPs, no peers, bad obfuscation).
  • New internal/web/service/xray_amneziawg_outbound_test.go: the generated-config swap preserves tag/order and is a byte-level no-op without AWG outbounds; CheckXrayConfig accepts a valid AWG outbound and rejects broken ones.
  • Full suite plus go vet ./... clean on a separate machine (Go 1.27 toolchain per go.mod).

Frontend (npm run typecheck, npm run lint, npm run test, npm run build all green — 127 files / 1215 tests):

  • New src/test/amneziawg-outbound-adapter.test.ts: wire → form → wire round-trip losslessness, default hydration, optional-field omission.

Manual flow exercised: add an amneziawg outbound via Outbound form → save template → generated config shows the socks bridge with the same tag pointing at 127.0.0.1:64900 → reconcile job brings up the client device (visible at AMNEZIAWGNET_DEBUG=1) → routing rules targeting the outbound's tag carry traffic through the tunnel.

Screenshots / recordings

N/A (form follows the existing Wireguard/AWG field layout; no new page).

Breaking changes

None. Templates without an amneziawg outbound are unaffected (the transform is a verified no-op there); existing inbound AWG behavior and stored settings are untouched.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes in the PR.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6309 **Author:** [@rqzbeh](https://github.com/rqzbeh) **Created:** 8/25/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/amneziawg-outbound` --- ### 📝 Commits (1) - [`beb8cb7`](https://github.com/MHSanaei/3x-ui/commit/beb8cb7feb9a96333e636b2f72e4101212de554f) feat(amneziawg): add AmneziaWG as an outbound protocol ### 📊 Changes **34 files changed** (+2005 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/lib/xray/outbound-form-adapter.ts` (+104 -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` (+89 -0) ➕ `internal/amneziawg/outbound.go` (+273 -0) ➕ `internal/amneziawg/outbound_test.go` (+201 -0) ➕ `internal/amneziawgnet/client_device.go` (+145 -0) 📝 `internal/amneziawgnet/device.go` (+11 -1) ➕ `internal/amneziawgnet/egress.go` (+386 -0) ➕ `internal/amneziawgnet/outbound_manager.go` (+170 -0) 📝 `internal/web/job/amneziawg_job.go` (+59 -0) 📝 `internal/web/service/xray.go` (+4 -0) ➕ `internal/web/service/xray_amneziawg_outbound.go` (+66 -0) ➕ `internal/web/service/xray_amneziawg_outbound_test.go` (+138 -0) 📝 `internal/web/service/xray_setting.go` (+14 -0) _...and 14 more files_ </details> ### 📄 Description ## Summary Adds AmneziaWG (AWG) as an **outbound** option, the outbound counterpart of the existing embedded AmneziaWG inbound support. An admin can now declare an `amneziawg` outbound in the Xray settings; the panel runs an amneziawg-go client device for it and routes Xray's traffic through that tunnel. ## 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). ## Type of change - [x] New feature - [ ] Bug fix - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [x] Frontend (UI / panel pages) - [x] Backend (API endpoints, login, settings) - [x] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? Backend (`go test ./...` — 41 packages green): - New `internal/amneziawg/outbound_test.go`: instance derivation + validation accept/reject matrix (bad endpoints, control chars, empty allowedIPs, no peers, bad obfuscation). - New `internal/web/service/xray_amneziawg_outbound_test.go`: the generated-config swap preserves tag/order and is a byte-level no-op without AWG outbounds; `CheckXrayConfig` accepts a valid AWG outbound and rejects broken ones. - Full suite plus `go vet ./...` clean on a separate machine (Go 1.27 toolchain per go.mod). Frontend (`npm run typecheck`, `npm run lint`, `npm run test`, `npm run build` all green — 127 files / 1215 tests): - New `src/test/amneziawg-outbound-adapter.test.ts`: wire → form → wire round-trip losslessness, default hydration, optional-field omission. Manual flow exercised: add an `amneziawg` outbound via Outbound form → save template → generated config shows the socks bridge with the same tag pointing at 127.0.0.1:64900 → reconcile job brings up the client device (visible at AMNEZIAWGNET_DEBUG=1) → routing rules targeting the outbound's tag carry traffic through the tunnel. ## Screenshots / recordings N/A (form follows the existing Wireguard/AWG field layout; no new page). ## Breaking changes None. Templates without an `amneziawg` outbound are unaffected (the transform is a verified no-op there); existing inbound AWG behavior and stored settings are untouched. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [x] `go build ./...` and the test suite pass locally. - [x] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes in the PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:07:09 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6215
No description provided.