[GH-ISSUE #6310] [Bug]: Clash subscription omits AmneziaWG entries #4282

Closed
opened 2026-10-31 20:38:32 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @xiaoxiyao on GitHub (Aug 25, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6310

Describe the bug

Clash subscription generated by 3x-ui omits AmneziaWG (amneziawg) proxy entries for enabled AmneziaWG clients.

How to reproduce the problem

  1. Create an AmneziaWG inbound (protocol = amneziawg) with a valid server block and enable it.
  2. Create a client for that inbound with a private key and enable the client.
  3. Assign the client to a subscription (subId) or set the client's SubID.
  4. Fetch the Clash subscription and inspect the returned YAML and search for proxies representing the AmneziaWG client (expected to see a proxy entry or equivalent).

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

3.7.0

Xray-core version

26.7.28

How did you install 3x-ui?

install.sh script

Operating system

Unknown

Which parts of the panel are affected?

Subscription (share links / Clash / JSON)

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

No — direct access

Before submitting

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
Originally created by @xiaoxiyao on GitHub (Aug 25, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6310 ### Describe the bug Clash subscription generated by 3x-ui omits AmneziaWG (amneziawg) proxy entries for enabled AmneziaWG clients. ### How to reproduce the problem 1. Create an AmneziaWG inbound (protocol = amneziawg) with a valid server block and enable it. 2. Create a client for that inbound with a private key and enable the client. 3. Assign the client to a subscription (subId) or set the client's SubID. 4. Fetch the Clash subscription and inspect the returned YAML and search for proxies representing the AmneziaWG client (expected to see a proxy entry or equivalent). ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.7.0 ### Xray-core version 26.7.28 ### How did you install 3x-ui? install.sh script ### Operating system Unknown ### Which parts of the panel are affected? Subscription (share links / Clash / JSON) ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? No — direct access ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:38:32 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@github-actions[bot] commented on GitHub (Aug 25, 2026):

Confirmed — the Clash generator has no amneziawg branch at all, so every AmneziaWG client is silently dropped from the /clash/ YAML. This is still true on the default branch (v3.7.0, the version you reported).

Where the client is dropped

The inbound is selected for the subscription — getInboundsBySubId lists the protocol explicitly:

// internal/sub/service.go:487
inbounds.protocol in ('vmess','vless','trojan','shadowsocks','hysteria','wireguard','amneziawg','mtproto')

and the raw /sub/ body builds a working link for it (internal/sub/service.go:638-639 → genAmneziaWGLink, emitting vpn://<base64url .conf>).

The Clash path then throws it away. SubClashService.buildProxy special-cases Hysteria and WireGuard, handles the four Xray protocols in a switch, and returns nil for everything else:

// internal/sub/clash_service.go:229-234
if inbound.Protocol == model.Hysteria { ... }
if inbound.Protocol == model.WireGuard {
    return s.buildWireguardProxy(subReq, inbound, client, ep)
}

// internal/sub/clash_service.go:285-287
default:
    return nil

model.AmneziaWG reaches that default (the earlier applyTransport call returns true for the empty network, internal/sub/clash_service.go:583), getProxies appends nothing, and if the sub contains only AmneziaWG clients GetClash returns an empty body at internal/sub/clash_service.go:71-73. The external-link Clash path has the same gap — clashProxyFromExternal switches on vmess/vless/trojan/shadowsocks/hysteria/wireguard only (internal/sub/clash_external.go:31-87).

The JSON subscription is affected too, and worse

Since you ticked "Subscription (share links / Clash / JSON)": SubJsonService.getConfig has the same missing branch (internal/sub/json_service.go:517-541), but unlike the WireGuard case it does not continue — it falls through to newOutbounds = append(newOutbounds, s.defaultOutbounds...) (internal/sub/json_service.go:543). The default outbounds are only direct (freedom) and block (blackhole) (internal/sub/default.json:45-63), while the routing rule sends all traffic to a tag that no longer exists:

// internal/sub/default.json:81-87
{ "type": "field", "network": "tcp,udp", "outboundTag": "proxy" }

So an AmneziaWG client gets a named config entry in /json/ that contains no proxy outbound at all.

Workaround until this is addressed

Use the raw subscription (/sub/) or the per-client export in the panel — both already produce a correct AmneziaWG payload. From the client list you can copy the vpn://… share link or download the .conf and import it into the AmneziaVPN/AmneziaWG app; see Configuration → AmneziaWG.

Verdict: Confirmed bug
Severity: Medium
Confidence: High
Root cause: SubClashService.buildProxy, internal/sub/clash_service.go:248-287 — the protocol switch has no model.AmneziaWG case, so an AmneziaWG inbound falls to default: return nil (line 285-287) and its clients never become Clash proxies. Triggering condition: any enabled amneziawg inbound whose clients carry the requested subId, fetched over /clash/. Same omission in SubJsonService.getConfig, internal/sub/json_service.go:517-541, and in clashProxyFromExternal, internal/sub/clash_external.go:31-87. Not a regression — AmneziaWG was never wired into these two generators; the raw-link path was (internal/sub/service.go:638).
Already fixed: Still present on the default branch (f727d04f, v3.7.0). The directly analogous defect for native WireGuard was fixed in d2efe9b0 "fix(sub): include native WireGuard clients in Clash and JSON subscriptions (#5676)" (released in v3.5.0), which added exactly the branches AmneziaWG is still missing.
Duplicate of: None. Related: #6302 (AmneziaWG as an outbound) and #6306 (AWG inbound clone/deploy) are separate root causes.
Evidence: internal/sub/service.go:487 (inbound is selected: 'wireguard','amneziawg','mtproto'); internal/sub/service.go:638-639 (case "amneziawg": return s.genAmneziaWGLink(...) — raw links work); internal/sub/clash_service.go:232-234 (WireGuard branch) vs :285-287 (default: return nil); internal/sub/clash_external.go:31-87; internal/sub/json_service.go:517-541 + :543; internal/sub/default.json:85 ("outboundTag": "proxy"); test TestGetInboundsBySubIdIncludesAmneziaWG (internal/sub/service_amneziawg_test.go:165) pins only the DB selection, and no test in internal/sub/clash_service_test.go covers AmneziaWG — so nothing asserts the current omission as intended.
Not determined: Whether mihomo can faithfully represent an AmneziaWG peer — its wireguard proxy would have to carry the obfuscation parameters the panel emits (Jc/Jmin/Jmax/S1/S2/H1-H4, and for 3.1 also I1-I5, HeaderProtectionKey, RandomTrailers, …; internal/sub/service.go:729-768). I could not verify mihomo's field names from this checkout, and a plain wireguard entry without them would never complete a handshake against an AmneziaWG server. Checking the mihomo WireGuardOption struct for an AmneziaWG option block settles it, and also settles whether the AmneziaWG 3.1 fields can be carried at all. Xray-core has no amneziawg outbound (the panel runs it itself in internal/amneziawgnet/), so the /json/ format most likely cannot carry it either.

Suggested fix: Mirror d2efe9b0 — add a model.AmneziaWG branch to buildProxy that emits a mihomo wireguard proxy plus its AmneziaWG option block, with the field names verified against mihomo's own source the way that commit did for the base WireGuard fields. If mihomo (or Xray, for /json/) cannot carry the obfuscation parameters, the client must be skipped explicitly instead — in getConfig that means a continue, so /json/ stops emitting an entry whose only outbounds are direct and block.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:5404551788 --> @github-actions[bot] commented on GitHub (Aug 25, 2026): Confirmed — the Clash generator has no `amneziawg` branch at all, so every AmneziaWG client is silently dropped from the `/clash/` YAML. This is still true on the default branch (v3.7.0, the version you reported). ### Where the client is dropped The inbound *is* selected for the subscription — `getInboundsBySubId` lists the protocol explicitly: ```go // internal/sub/service.go:487 inbounds.protocol in ('vmess','vless','trojan','shadowsocks','hysteria','wireguard','amneziawg','mtproto') ``` and the raw `/sub/` body builds a working link for it (`internal/sub/service.go:638-639` → `genAmneziaWGLink`, emitting `vpn://<base64url .conf>`). The Clash path then throws it away. `SubClashService.buildProxy` special-cases Hysteria and WireGuard, handles the four Xray protocols in a `switch`, and returns `nil` for everything else: ```go // internal/sub/clash_service.go:229-234 if inbound.Protocol == model.Hysteria { ... } if inbound.Protocol == model.WireGuard { return s.buildWireguardProxy(subReq, inbound, client, ep) } // internal/sub/clash_service.go:285-287 default: return nil ``` `model.AmneziaWG` reaches that `default` (the earlier `applyTransport` call returns `true` for the empty network, `internal/sub/clash_service.go:583`), `getProxies` appends nothing, and if the sub contains only AmneziaWG clients `GetClash` returns an empty body at `internal/sub/clash_service.go:71-73`. The external-link Clash path has the same gap — `clashProxyFromExternal` switches on `vmess/vless/trojan/shadowsocks/hysteria/wireguard` only (`internal/sub/clash_external.go:31-87`). ### The JSON subscription is affected too, and worse Since you ticked "Subscription (share links / Clash / JSON)": `SubJsonService.getConfig` has the same missing branch (`internal/sub/json_service.go:517-541`), but unlike the WireGuard case it does not `continue` — it falls through to `newOutbounds = append(newOutbounds, s.defaultOutbounds...)` (`internal/sub/json_service.go:543`). The default outbounds are only `direct` (freedom) and `block` (blackhole) (`internal/sub/default.json:45-63`), while the routing rule sends all traffic to a tag that no longer exists: ```json // internal/sub/default.json:81-87 { "type": "field", "network": "tcp,udp", "outboundTag": "proxy" } ``` So an AmneziaWG client gets a named config entry in `/json/` that contains no proxy outbound at all. ### Workaround until this is addressed Use the raw subscription (`/sub/`) or the per-client export in the panel — both already produce a correct AmneziaWG payload. From the client list you can copy the `vpn://…` share link or download the `.conf` and import it into the AmneziaVPN/AmneziaWG app; see [Configuration → AmneziaWG](https://docs.sanaei.dev/en/docs/config/amneziawg). Verdict: Confirmed bug Severity: Medium Confidence: High Root cause: `SubClashService.buildProxy`, `internal/sub/clash_service.go:248-287` — the protocol `switch` has no `model.AmneziaWG` case, so an AmneziaWG inbound falls to `default: return nil` (line 285-287) and its clients never become Clash proxies. Triggering condition: any enabled `amneziawg` inbound whose clients carry the requested `subId`, fetched over `/clash/`. Same omission in `SubJsonService.getConfig`, `internal/sub/json_service.go:517-541`, and in `clashProxyFromExternal`, `internal/sub/clash_external.go:31-87`. Not a regression — AmneziaWG was never wired into these two generators; the raw-link path was (`internal/sub/service.go:638`). Already fixed: Still present on the default branch (`f727d04f`, v3.7.0). The directly analogous defect for native WireGuard was fixed in `d2efe9b0` "fix(sub): include native WireGuard clients in Clash and JSON subscriptions (#5676)" (released in v3.5.0), which added exactly the branches AmneziaWG is still missing. Duplicate of: None. Related: #6302 (AmneziaWG as an *outbound*) and #6306 (AWG inbound clone/deploy) are separate root causes. Evidence: `internal/sub/service.go:487` (inbound is selected: `'wireguard','amneziawg','mtproto'`); `internal/sub/service.go:638-639` (`case "amneziawg": return s.genAmneziaWGLink(...)` — raw links work); `internal/sub/clash_service.go:232-234` (WireGuard branch) vs `:285-287` (`default: return nil`); `internal/sub/clash_external.go:31-87`; `internal/sub/json_service.go:517-541` + `:543`; `internal/sub/default.json:85` (`"outboundTag": "proxy"`); test `TestGetInboundsBySubIdIncludesAmneziaWG` (`internal/sub/service_amneziawg_test.go:165`) pins only the DB selection, and no test in `internal/sub/clash_service_test.go` covers AmneziaWG — so nothing asserts the current omission as intended. Not determined: Whether mihomo can faithfully represent an AmneziaWG peer — its `wireguard` proxy would have to carry the obfuscation parameters the panel emits (`Jc`/`Jmin`/`Jmax`/`S1`/`S2`/`H1`-`H4`, and for 3.1 also `I1`-`I5`, `HeaderProtectionKey`, `RandomTrailers`, …; `internal/sub/service.go:729-768`). I could not verify mihomo's field names from this checkout, and a plain `wireguard` entry without them would never complete a handshake against an AmneziaWG server. Checking the mihomo `WireGuardOption` struct for an AmneziaWG option block settles it, and also settles whether the AmneziaWG 3.1 fields can be carried at all. Xray-core has no `amneziawg` outbound (the panel runs it itself in `internal/amneziawgnet/`), so the `/json/` format most likely cannot carry it either. Suggested fix: Mirror `d2efe9b0` — add a `model.AmneziaWG` branch to `buildProxy` that emits a mihomo `wireguard` proxy plus its AmneziaWG option block, with the field names verified against mihomo's own source the way that commit did for the base WireGuard fields. If mihomo (or Xray, for `/json/`) cannot carry the obfuscation parameters, the client must be skipped explicitly instead — in `getConfig` that means a `continue`, so `/json/` stops emitting an entry whose only outbounds are `direct` and `block`. *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
Author
Owner

@VibeProgramm commented on GitHub (Aug 25, 2026):

Confirmed on another instance:

  • 3x-ui version: 3.7.0
  • Xray-core: 26.7.28
  • OS: Debian 13 (trixie)
  • Install: install.sh script

Reproduction:

  1. AmneziaWG inbound enabled on port 53811 with 8 clients
  2. Fetched Clash subscription via https://<panel>/clash/{subId}
  3. Result: amneziawg appears in proxy-groups but has no proxy definition in proxies section

Clash output (redacted):

proxies:
- name: RU-TCP-Reality-...
  type: vless
  ...
- name: RU-XHTTP-Reality-...
  type: vless
  ...
- name: hysteria
  type: hysteria2
  ...
# ← NO amneziawg proxy defined here

proxy-groups:
- name: PROXY
  proxies:
  - RU-TCP-Reality-...
  - RU-XHTTP-Reality-...
  - hysteria
  - amneziawg  # ← references undefined proxy

The subscription endpoint also generates a vpn:// link for AmneziaWG in the /clients/links/ API response, but the Clash YAML conversion is missing. This breaks Clash/mihomo clients as they cannot resolve the amneziawg proxy reference.

<!-- gh-comment-id:5413016680 --> @VibeProgramm commented on GitHub (Aug 25, 2026): Confirmed on another instance: - **3x-ui version**: 3.7.0 - **Xray-core**: 26.7.28 - **OS**: Debian 13 (trixie) - **Install**: install.sh script **Reproduction**: 1. AmneziaWG inbound enabled on port 53811 with 8 clients 2. Fetched Clash subscription via `https://<panel>/clash/{subId}` 3. Result: `amneziawg` appears in `proxy-groups` but has **no proxy definition** in `proxies` section **Clash output** (redacted): ```yaml proxies: - name: RU-TCP-Reality-... type: vless ... - name: RU-XHTTP-Reality-... type: vless ... - name: hysteria type: hysteria2 ... # ← NO amneziawg proxy defined here proxy-groups: - name: PROXY proxies: - RU-TCP-Reality-... - RU-XHTTP-Reality-... - hysteria - amneziawg # ← references undefined proxy ``` The subscription endpoint also generates a `vpn://` link for AmneziaWG in the `/clients/links/` API response, but the Clash YAML conversion is missing. This breaks Clash/mihomo clients as they cannot resolve the `amneziawg` proxy reference.
Author
Owner

@VibeProgramm commented on GitHub (Aug 25, 2026):

PR with fix: https://github.com/MHSanaei/3x-ui/pull/6326

Adds buildAmneziaWGProxy to generate mihomo-compatible Clash proxy entries with amnezia-wg-option sub-block for AmneziaWG inbounds. Supports v1.0, v1.5, and v3 (header protection, content padding, timing, random-trailers, disable-cookies) obfuscation fields.

<!-- gh-comment-id:5413395944 --> @VibeProgramm commented on GitHub (Aug 25, 2026): PR with fix: https://github.com/MHSanaei/3x-ui/pull/6326 Adds `buildAmneziaWGProxy` to generate mihomo-compatible Clash proxy entries with `amnezia-wg-option` sub-block for AmneziaWG inbounds. Supports v1.0, v1.5, and v3 (header protection, content padding, timing, random-trailers, disable-cookies) obfuscation fields.
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#4282
No description provided.