[PR #6326] [MERGED] feat(sub): add AmneziaWG proxy generation for Clash subscriptions #6219

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6326
Author: @VibeProgramm
Created: 8/25/2026
Status: ✅ Merged
Merged: 9/10/2026
Merged by: @MHSanaei

Base: main ← Head: feat/amneziawg-clash-subscription


📝 Commits (6)

  • e45d74a feat(sub): add AmneziaWG proxy generation for Clash subscriptions
  • 88889bf fix review nits: doc comment and test call
  • a8a4bf8 fix(sub): use the AmneziaWG inbound's own tunnel address in Clash proxies
  • 5220dba Merge remote-tracking branch 'origin/main' into pr/6326
  • 46fd2f5 fix(sub): emit the AmneziaWG effective MTU in Clash proxies
  • ba18727 fix(sub): reject a zoned DNS address before opting into remote-dns-resolve

📊 Changes

2 files changed (+584 additions, -0 deletions)

View changed files

📝 internal/sub/clash_service.go (+185 -0)
📝 internal/sub/clash_service_test.go (+399 -0)

📄 Description

Summary

Add buildAmneziaWGProxy to generate mihomo-compatible wireguard proxy entries with amnezia-wg-option sub-block for AmneziaWG inbounds in Clash subscriptions.

Why

Previously, AmneziaWG inbounds were silently skipped in Clash subscriptions (buildProxy returned nil), making them unusable with mihomo/Clash clients. This fixes #6310.

Type of change

  • Bug fix
  • New feature
  • 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?

  1. go build ./... — passes
  2. go test ./internal/sub/ -run AmneziaWG -v — 3 new tests pass:
    • TestBuildAmneziaWGProxyForClash — v1.0 obfuscation fields
    • TestBuildAmneziaWGProxyForClashV3 — v3 fields (headerProtectionKey, randomTrailers, etc.)
    • TestBuildAmneziaWGProxyForClashNoKey — nil when client has no key
  3. go vet ./internal/sub/ — no issues
  4. make gen-check — passes
  5. All existing tests continue to pass

What the Clash YAML output looks like

proxies:
  - name: "amneziawg - user"
    type: wireguard
    server: 203.0.113.7
    port: 51820
    private-key: <client-privkey>
    public-key: <server-pubkey>
    ip: 10.8.1.2
    udp: true
    amnezia-wg-option:
      version: 3
      jc: 3
      jmin: 66
      jmax: 150
      s1: 147
      s2: 146
      s3: 28
      s4: 27
      h1: "364198942-470015235"
      h2: "1041963382-1068354159"
      h3: "1313106728-1361756201"
      h4: "1801896583-1875457201"
      header-protection-key: DmVT7JtmJM8YoHiA2Wp3xPKI5dTXFx83y2JUQkKg1p8=
      content-padding-addition: 9-31
      random-trailers: true
      disable-cookies: true

Breaking changes

None.

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 mixed into this PR.

Closes #6310


🔄 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/6326 **Author:** [@VibeProgramm](https://github.com/VibeProgramm) **Created:** 8/25/2026 **Status:** ✅ Merged **Merged:** 9/10/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `feat/amneziawg-clash-subscription` --- ### 📝 Commits (6) - [`e45d74a`](https://github.com/MHSanaei/3x-ui/commit/e45d74a0db1040aad070fb5ab5866ccee38a8ec3) feat(sub): add AmneziaWG proxy generation for Clash subscriptions - [`88889bf`](https://github.com/MHSanaei/3x-ui/commit/88889bfbf46962531e47aa60723886fde3cf22ee) fix review nits: doc comment and test call - [`a8a4bf8`](https://github.com/MHSanaei/3x-ui/commit/a8a4bf8cc77432a13cb1acca05c498e42cca8a85) fix(sub): use the AmneziaWG inbound's own tunnel address in Clash proxies - [`5220dba`](https://github.com/MHSanaei/3x-ui/commit/5220dba7741a4694f7824ae2a0e2effd9cfa2860) Merge remote-tracking branch 'origin/main' into pr/6326 - [`46fd2f5`](https://github.com/MHSanaei/3x-ui/commit/46fd2f5829e50e068a9b614450942b33e0953db6) fix(sub): emit the AmneziaWG effective MTU in Clash proxies - [`ba18727`](https://github.com/MHSanaei/3x-ui/commit/ba18727c564be69fd07707e0fa6f6a19bad85a1b) fix(sub): reject a zoned DNS address before opting into remote-dns-resolve ### 📊 Changes **2 files changed** (+584 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `internal/sub/clash_service.go` (+185 -0) 📝 `internal/sub/clash_service_test.go` (+399 -0) </details> ### 📄 Description ## Summary Add `buildAmneziaWGProxy` to generate mihomo-compatible wireguard proxy entries with `amnezia-wg-option` sub-block for AmneziaWG inbounds in Clash subscriptions. ## Why Previously, AmneziaWG inbounds were silently skipped in Clash subscriptions (`buildProxy` returned nil), making them unusable with mihomo/Clash clients. This fixes #6310. ## Type of change - [x] Bug fix - [ ] New feature - [ ] 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 - [x] 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? 1. `go build ./...` — passes 2. `go test ./internal/sub/ -run AmneziaWG -v` — 3 new tests pass: - `TestBuildAmneziaWGProxyForClash` — v1.0 obfuscation fields - `TestBuildAmneziaWGProxyForClashV3` — v3 fields (headerProtectionKey, randomTrailers, etc.) - `TestBuildAmneziaWGProxyForClashNoKey` — nil when client has no key 3. `go vet ./internal/sub/` — no issues 4. `make gen-check` — passes 5. All existing tests continue to pass ## What the Clash YAML output looks like ```yaml proxies: - name: "amneziawg - user" type: wireguard server: 203.0.113.7 port: 51820 private-key: <client-privkey> public-key: <server-pubkey> ip: 10.8.1.2 udp: true amnezia-wg-option: version: 3 jc: 3 jmin: 66 jmax: 150 s1: 147 s2: 146 s3: 28 s4: 27 h1: "364198942-470015235" h2: "1041963382-1068354159" h3: "1313106728-1361756201" h4: "1801896583-1875457201" header-protection-key: DmVT7JtmJM8YoHiA2Wp3xPKI5dTXFx83y2JUQkKg1p8= content-padding-addition: 9-31 random-trailers: true disable-cookies: true ``` ## Breaking changes None. ## 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. - [ ] 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 mixed into this PR. Closes #6310 --- <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:11 +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#6219
No description provided.