mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6508] [MERGED] fix(sub): drop external Clash shadowsocks nodes the panel cannot express #6318
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#6318
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/6508
Author: @BlindMaster24
Created: 9/13/2026
Status: ✅ Merged
Merged: 9/13/2026
Merged by: @MHSanaei
Base:
main← Head:fix/clash-shadowsocks-obfs-gate📝 Commits (3)
fb7045bfix(sub): gate external Clash shadowsocks links like the inbound path41921dffix(sub): count a dropped external link in the quota header8dce470docs(sub): describe clashProxyFromExternal by what it does, not by protocol📊 Changes
4 files changed (+200 additions, -8 deletions)
View changed files
📝
internal/sub/clash_external.go(+4 -6)➕
internal/sub/clash_external_quota_test.go(+118 -0)➕
internal/sub/clash_external_shadowsocks_test.go(+75 -0)📝
internal/sub/clash_service.go(+3 -2)📄 Description
Summary
clashProxyFromExternalreturned as soon as it had built the shadowsocks proxy, so anss://link skipped the transport/security mapping that every other protocol — and the inbound path — goes through.Why
Pasting an
ss://link into an external Clash subscription produced a proxy built fromtype/server/port/cipher/passwordalone. Two user-visible consequences:1. TCP/HTTP obfuscation was ignored, and the node was not dropped. mihomo cannot express an xray
tcpSettings.header.type=httpon a shadowsocks proxy, which is whyapplyTransportreturns false and the inbound path (buildProxy→applyTransport→getProxies) omits such a node: the YAML ships with a working set of proxies. The external-link path emitted it anyway, so mihomo opens a plain shadowsocks stream at a server that requires the HTTP header. The node appears in the subscription, the client shows it, and it silently never connects — the same failure mode as #6505, one layer further along. Pasting the identical node as an inbound and as a link produced two mutually inconsistent configs.2. TLS was silently stripped. For
security=tlsthe link path never calledapplySecurity, so the proxy carried notls: true/servername— a plaintext stream at a TLS listener.3. And once the node is dropped, it took the client's quota with it. The client email that feeds
AggregateTrafficByEmailswas recorded only when a link produced a proxy (clash_service.go:91-93), so a dropped node also disappeared from theSubscription-Userinfoheader — a two-client subscription served A's numbers as the whole subscription's numbers. The!ext.Activebranch already counted an email without a proxy, so the rule is now unconditional; that fixes the same under-report for the vmess/vless/trojan links that were already droppable (?type=kcp, unknownsecurity=).The panel's own
genShadowsocksLinkwrites obfs asplugin=obfs-local;obfs=http;obfs-host=…(SIP002, pinned byTestShadowsocksTcpHttpHeaderUsesObfsLocalPlugin). #6505 maps that plugin onto the tcp/http header on import, so both spellings of the same link now reach this gate. The xray-native spelling (?type=tcp&headerType=http) reaches it onmaintoday, which is what the test below uses, so this PR stands on its own.Type of change
Areas affected
How was this tested?
New
TestClashExternalShadowsocksMatchesInboundPathbuilds the same shadowsocks node twice — once as an inbound throughbuildProxy, once as a share link throughclashProxyFromExternal— and requires the two results to agree, for three links:?type=tcp(plain)?type=tcp&headerType=http&host=test?type=tcp&security=tls&sni=ss.sniBefore the fix, all three rows fail — the interesting one is the obfs row, where the inbound path returns
niland the link path returns a proxy:The fix is the
sscase no longer returning early, so it falls into the shared transport/security tail; all three rows then pass, with the link and inbound proxies deep-equal apart fromname.TestClashQuotaHeaderCountsDroppedExternalLinkdrives the whole HTTP path: a subscription with client A on an inbound (11/22/1024) and client B on an obfsss://link (100/200/2048). Without the quota change the header isupload=11; download=22; total=1024— A alone — and with itupload=111; download=222; total=3072.TestClashAllUnrepresentableNodesAnswerAlikepins that a subscription with nothing representable answers the same way whether the node came from an inbound or an external link (it compares the two responses instead of asserting a particular status).go test ./internal/sub/— ok (39s)go test ./internal/util/link/— okgo vet ./internal/sub/— cleangofmt -l internal/sub/ internal/util/link/— cleanThere is no C toolchain on this machine, so the CGo SQLite driver cannot build here: I ran the packages with
CGO_ENABLED=0plus an overlay replacing the three CGo SQLite call sites ininternal/databasewith a pure-Go driver. Every file in this PR is the real one, unmodified by the overlay. CI stays the authority ongo build ./...with the real driver.Screenshots / recordings
N/A (no UI change).
Breaking changes
None for existing working subscriptions. Two behaviour changes worth stating plainly:
ss://node whose transport Clash cannot express is now dropped from the profile, exactly as the same node as an inbound always has been. A subscription whose only node was such a link answers 404 with an empty body instead of serving a profile with one non-connecting proxy — the same answer the inbound path gives for the same node, and what an external vmess/vless/trojan link with?type=kcpalready gets onmain. Clients keep the profile they last fetched.security=tlsshadowsocks links gaintls: true/servername, and a dropped external node still contributes toSubscription-Userinfo. The quota header of a mixed subscription changes (up) as a result.Checklist
go build ./...and the test suite pass locally. — no C compiler here, ran with the cgo-free overlay described above; CI verifies the real build.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.