mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6505] [MERGED] fix(link): rebuild shadowsocks tcp/http obfuscation on import #6317
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#6317
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/6505
Author: @BlindMaster24
Created: 9/13/2026
Status: ✅ Merged
Merged: 9/13/2026
Merged by: @MHSanaei
Base:
main← Head:fix/link-shadowsocks-plugin-import📝 Commits (2)
8bcdbb8fix(link): rebuild shadowsocks tcp/http obfuscation on import0573de8fix(link): map the SIP002 plugin in both importers📊 Changes
5 files changed (+187 additions, -0 deletions)
View changed files
📝
frontend/src/lib/xray/outbound-link-parser.ts(+22 -0)📝
frontend/src/test/outbound-link-parser.test.ts(+21 -0)➕
internal/sub/shadowsocks_plugin_import_test.go(+49 -0)📝
internal/util/link/outbound.go(+51 -0)📝
internal/util/link/outbound_test.go(+44 -0)📄 Description
Summary
ParseLinknow rebuilds the tcp/http response header a shadowsocks link describes through the SIP002plugin=obfs-localparameter. Importing a link the panel had just exported no longer throws the obfuscation away.Why
genShadowsocksLinkexports tcp/http obfuscation only as the SIP002 plugin parameter. That is deliberate —internal/sub/service.go:1303-1310says why:The importer read none of it.
parseShadowsockspassed onlytype/security/sni/alpn/fpintoapplyTransport, and the emitter had just deleted four of those, so a link round-tripped through the panel lost the one thing that made it work.Reproduced against the current
mainwith the export path itself, not a hand-written string:The header is
none. The inbound behind that link speakstcp/header.type: http, so the imported outbound cannot connect to it.Operator scenario. Someone runs a 3x-ui panel with a shadowsocks inbound using TCP + HTTP-header obfuscation (a common way to make an SS inbound look like plain HTTP). They hand out the share link, or point a second 3x-ui node at it with an external subscription. Both import paths end in
link.ParseLink—internal/sub/external_config.go:216for a pasted link,internal/web/service/outbound_subscription.go:394for a fetched subscription. What lands in the second panel is a plain-TCP SS outbound: it saves fine, shows no error, and simply never connects. The same link in v2rayN works, because v2rayN readsplugin, so the first panel looks correct and the second one looks broken. The other direction — the panel's own JSON/Clash output — never goes throughParseLinkand is unaffected.This is the same class as #6467, which preserved the shadowsocks TLS query params on import in this function; the plugin parameter was the remaining unread one.
What changed
applyObfsLocalPluginmapsplugin=obfs-local;obfs=http;obfs-host=<host>ontotype=tcp,headerType=http,host=<host>— exactly the four keys the emitter deleted, so the existingapplyTransportbranch rebuildstcpSettings.header(withpath: ["/"], matching the emitter's note that SIP002 clients force/).obfs=httpis mapped.obfs=tlsand third-party plugins (v2ray-plugin, …) are left alone, because Xray has no header that corresponds to them and guessing would be worse than the current silence. Both cases are asserted.headerType/type=httpin the link wins; the helper returns early rather than overwriting it.mporthandling, theidentitystring (and therefore import dedup) and every other protocol are untouched.Type of change
Areas affected
How was this tested?
Two tests, and both were watched going red without the fix (by running them against
main'soutbound.go):internal/sub/shadowsocks_plugin_import_test.go— the round trip, driven through the real exporter:genShadowsocksLinkon a tcp/http inbound, thenlink.ParseLinkon the result. Assertsheader.type == "http"and theobfs-hostsurvives. Without the fix it fails with{"header":{"type":"none"}}.internal/util/link/outbound_test.go—TestParseShadowsocksObfsLocalPlugin, a table over the three plugin shapes:obfs=httpbecomes the header,obfs=tlsandv2ray-pluginstaynone. Without the fix the first row fails withheader = map[type:none], want type "http".Local run: this machine has no C compiler, so the Go tests ran with a pure-Go SQLite driver (
modernc.org/sqlite) substituted behindgo build -overlay, whose only entries areinternal/database's driver call sites.go test ./internal/util/link/ ./internal/sub/— both green;gofmtandgo vetclean on both packages. The existing shadowsocks cases inTestParseShadowsocks, including the two that already carried aplugin=query, still pass; they only asserted credentials, so the new mapping is the behaviour change they never pinned.Screenshots / recordings
N/A — wire format, covered above.
Breaking changes
None.
Checklist
go build ./...and the test suite pass locally. (as-is they need the CGo driver; CI covers that)npm run lint,npm run typecheck, andnpm run buildpass. (no frontend change in this PR)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.