[PR #6838] [MERGED] feat(sub): map shadowsocks tcp http header to mihomo obfs plugin #6475

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6838
Author: @EmmaHermione
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/24/2026
Merged by: @MHSanaei

Base: main ← Head: feat/mihomo-ss-tcp-http-obfs


📝 Commits (5)

  • 0337713 feat(sub): map shadowsocks tcp http header to mihomo obfs plugin
  • 14269b7 Merge remote-tracking branch 'origin/main' into pr/6838
  • 1e8ec69 fix(sub): map shadowsocks HTTP headers to obfs only when they accept /
  • f4f14c9 Merge remote-tracking branch 'origin/main' into pr/6838
  • c3d5788 style(sub): group the kcp fixture constants for gofumpt

📊 Changes

4 files changed (+199 additions, -11 deletions)

View changed files

📝 internal/sub/clash_external_quota_test.go (+7 -7)
📝 internal/sub/clash_external_shadowsocks_test.go (+1 -1)
📝 internal/sub/clash_service.go (+65 -3)
📝 internal/sub/clash_service_test.go (+126 -0)

📄 Description

Summary

Resolves #6735.

Maps Shadowsocks inbounds and external links configured with TCP HTTP obfuscation (network: tcp with header.type: http) to Mihomo's built-in plugin: obfs (mode: http, host: ...) instead of dropping the proxy entirely from /mihomo/ subscriptions.

Why

  1. In PR #6508, Shadowsocks nodes with TCP HTTP headers were dropped under the rationale that Clash cannot express them. While true for legacy Clash (which lacks built-in obfs), Mihomo (Clash.Meta) natively supports simple-obfs out of the box via plugin: obfs without requiring external binaries.
  2. The panel's own plain share link generator (genShadowsocksLink) already re-encodes this exact configuration into plugin=obfs-local;obfs=http;obfs-host=... (pinned by TestShadowsocksTcpHttpHeaderUsesObfsLocalPlugin). This PR aligns the Mihomo/Clash subscription path with that existing behavior.
  3. Both the inbound path (buildProxy) and external share links (clashProxyFromExternal) remain in complete lockstep parity.

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. Targeted Unit Tests:
    Executed the relevant test suite verifying both inbound and external link paths:
    go test -v ./internal/sub/ -run "TestClashExternalShadowsocksMatchesInboundPath|TestApplyTransport_TCPHeader|TestClashQuotaHeaderCountsDroppedExternalLink|TestClashAllUnrepresentableNodesAnswerAlike"

    • TestClashExternalShadowsocksMatchesInboundPath: Verified that both inbound Shadowsocks and external ss:// share links with TCP HTTP headers generate identical proxy configs with plugin: obfs (mode: http, host: test).
    • TestApplyTransport_TCPHeader: Verified that Shadowsocks is accepted and mapped to plugin: obfs across real panel inbound payloads (including empty response headers) and multiple host formats (string/slice), while generic protocols (VMess, Trojan, VLESS) continue to be rejected as unrepresentable.
    • TestClashQuotaHeaderCountsDroppedExternalLink & TestClashAllUnrepresentableNodesAnswerAlike: Verified that truly unrepresentable transports (kcp) remain dropped while traffic quota continues to accumulate accurately.
  2. Package-level Test Suite:
    Ran the entire subscription package test suite to verify zero regressions:
    go test ./internal/sub/
    All test cases passed cleanly.

  3. Code Quality & Linting:
    Executed standard formatting and static analysis:
    gofmt -s -w internal/sub/
    go vet ./internal/sub/
    Clean output with zero issues.

Screenshots / recordings

N/A (subscription backend logic change, no UI changes).

Breaking changes

None. Existing working subscriptions remain unaffected. Shadowsocks nodes configured with TCP HTTP obfuscation that were previously omitted from Mihomo subscriptions are now properly exported with native plugin: obfs.

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.

🔄 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/6838 **Author:** [@EmmaHermione](https://github.com/EmmaHermione) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/24/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `feat/mihomo-ss-tcp-http-obfs` --- ### 📝 Commits (5) - [`0337713`](https://github.com/MHSanaei/3x-ui/commit/0337713391f2bea137eb9100c4c3b3ecee07bb51) feat(sub): map shadowsocks tcp http header to mihomo obfs plugin - [`14269b7`](https://github.com/MHSanaei/3x-ui/commit/14269b7277c548bf218846042838ce4e188d8f17) Merge remote-tracking branch 'origin/main' into pr/6838 - [`1e8ec69`](https://github.com/MHSanaei/3x-ui/commit/1e8ec69eab1dcf625b5e5ce3e80325c23b63d3ff) fix(sub): map shadowsocks HTTP headers to obfs only when they accept / - [`f4f14c9`](https://github.com/MHSanaei/3x-ui/commit/f4f14c9b39f38c692fe18b210e1028e7ee02acfa) Merge remote-tracking branch 'origin/main' into pr/6838 - [`c3d5788`](https://github.com/MHSanaei/3x-ui/commit/c3d5788d1f29ff47bac7c25405d6915a004c976d) style(sub): group the kcp fixture constants for gofumpt ### 📊 Changes **4 files changed** (+199 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `internal/sub/clash_external_quota_test.go` (+7 -7) 📝 `internal/sub/clash_external_shadowsocks_test.go` (+1 -1) 📝 `internal/sub/clash_service.go` (+65 -3) 📝 `internal/sub/clash_service_test.go` (+126 -0) </details> ### 📄 Description ## Summary Resolves #6735. Maps Shadowsocks inbounds and external links configured with TCP HTTP obfuscation (`network: tcp` with `header.type: http`) to Mihomo's built-in `plugin: obfs` (`mode: http, host: ...`) instead of dropping the proxy entirely from `/mihomo/` subscriptions. ## Why 1. In PR #6508, Shadowsocks nodes with TCP HTTP headers were dropped under the rationale that Clash cannot express them. While true for legacy Clash (which lacks built-in obfs), **Mihomo (Clash.Meta) natively supports simple-obfs out of the box** via `plugin: obfs` without requiring external binaries. 2. The panel's own plain share link generator (`genShadowsocksLink`) already re-encodes this exact configuration into `plugin=obfs-local;obfs=http;obfs-host=...` (pinned by `TestShadowsocksTcpHttpHeaderUsesObfsLocalPlugin`). This PR aligns the Mihomo/Clash subscription path with that existing behavior. 3. Both the inbound path (`buildProxy`) and external share links (`clashProxyFromExternal`) remain in complete lockstep parity. ## Type of change - [x] Bug fix - [x] 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. Targeted Unit Tests: Executed the relevant test suite verifying both inbound and external link paths: `go test -v ./internal/sub/ -run "TestClashExternalShadowsocksMatchesInboundPath|TestApplyTransport_TCPHeader|TestClashQuotaHeaderCountsDroppedExternalLink|TestClashAllUnrepresentableNodesAnswerAlike"` - TestClashExternalShadowsocksMatchesInboundPath: Verified that both inbound Shadowsocks and external ss:// share links with TCP HTTP headers generate identical proxy configs with plugin: obfs (mode: http, host: test). - TestApplyTransport_TCPHeader: Verified that Shadowsocks is accepted and mapped to plugin: obfs across real panel inbound payloads (including empty response headers) and multiple host formats (string/slice), while generic protocols (VMess, Trojan, VLESS) continue to be rejected as unrepresentable. - TestClashQuotaHeaderCountsDroppedExternalLink & TestClashAllUnrepresentableNodesAnswerAlike: Verified that truly unrepresentable transports (kcp) remain dropped while traffic quota continues to accumulate accurately. 2. Package-level Test Suite: Ran the entire subscription package test suite to verify zero regressions: `go test ./internal/sub/` All test cases passed cleanly. 3. Code Quality & Linting: Executed standard formatting and static analysis: `gofmt -s -w internal/sub/` `go vet ./internal/sub/` Clean output with zero issues. ## Screenshots / recordings N/A (subscription backend logic change, no UI changes). ## Breaking changes None. Existing working subscriptions remain unaffected. Shadowsocks nodes configured with TCP HTTP obfuscation that were previously omitted from Mihomo subscriptions are now properly exported with native plugin: obfs. ## 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:09:02 +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#6475
No description provided.