mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #5676] [MERGED] fix(sub): include native WireGuard clients in Clash and JSON subscriptions #5955
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#5955
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/5676
Author: @STRENCH0
Created: 6/30/2026
Status: ✅ Merged
Merged: 7/8/2026
Merged by: @MHSanaei
Base:
main← Head:fix/wireguard-clash-json-sub📝 Commits (2)
7dd2952fix(sub): include native WireGuard clients in Clash and JSON subscriptions9cbb1b5Merge branch 'main' into fix/wireguard-clash-json-sub📊 Changes
4 files changed (+275 additions, -0 deletions)
View changed files
📝
internal/sub/clash_service.go(+65 -0)📝
internal/sub/clash_service_test.go(+79 -0)📝
internal/sub/json_service.go(+56 -0)📝
internal/sub/json_service_test.go(+75 -0)📄 Description
The Clash (buildProxy) and JSON (getConfig) subscription generators had no WireGuard branch, so a native WireGuard inbound's clients were silently dropped: buildProxy hit its default nil case, and getConfig emitted a config with no proxy outbound. Only the raw subscription (genWireguardLink) and external-link Clash path handled WireGuard.
Add a WireGuard case to both generators, mirroring genWireguardLink: the peer public key is derived from the inbound secretKey, while the private key, tunnel address (mihomo ip/ipv6, Xray settings.address), pre-shared key and keep-alive come from the client. The peer routes the full tunnel (0.0.0.0/0, ::/0), which both mihomo and Xray also default to. Field names verified against the mihomo WireGuardOption source and the Xray wireguard outbound schema.
Summary
Native WireGuard inbounds now appear in the Clash and JSON subscriptions. Their clients were previously dropped from both formats.
Why
The Clash (
buildProxy) and JSON (getConfig) subscription generators had no WireGuard branch. For a native WireGuard inbound:buildProxyfell through to itsdefault: return nil, so the client never made it into the YAML (and thus never into thePROXYproxy-group).getConfig's protocol switch had nowireguardcase, so the emitted config had no proxy outbound — an unusable entry.Only the raw subscription (
genWireguardLink) and the external-link Clash path (clashWireguardFromExternal) handled WireGuard, which is why WG clients silently went missing from Clash/JSON subs.Type of change
Areas affected
How was this tested?
New table-free unit tests in
internal/sub, mirroring the existing generator tests:TestBuildWireguardProxyForClash/TestBuildWireguardProxyForClashNoKey— asserts the mihomo proxy fields (type,server,port,private-key,public-keyderived from the inboundsecretKey,pre-shared-key,ip/ipv6,mtu,dns,udp) and the keyless →nilpath.TestSubJsonServiceWireguard/TestSubJsonServiceWireguardNoKey— asserts the Xraywireguardoutbound (secretKey,address,peers[]withpublicKey/endpoint/allowedIPsfull tunnel/preSharedKey/keepAlive,mtu) and the keyless →nilpath.Field names were verified against the upstream mihomo
WireGuardOptionsource and the Xraywireguardoutbound schema.Full local gate passed:
make verify(gen-check, lint, typecheck, test, build) — OKgolangci-lint run ./internal/sub/— 0 issuesManual testing:
Spun up a 3x-ui panel locally, created a WireGuard connection and a subscription. Verified that clash and json subscriptions now include the WireGuard config
Screenshots / recordings
N/A — no UI changes.
Breaking changes
None.
Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.