[GH-ISSUE #6735] [Feature]: Map Shadowsocks TCP HTTP header to Mihomo 'plugin: obfs' instead of dropping the node from the Mihomo subscription #4486

Closed
opened 2026-10-31 20:39:59 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @EmmaHermione on GitHub (Oct 5, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6735

Describe the bug

When generating Clash/Mihomo subscriptions (/mihomo/<sub-id> or /clash/<sub-id>), any Shadowsocks inbound (both legacy AEAD and 2022 methods) configured with TCP HTTP obfuscation (network: tcp with header.type: http) is completely omitted from the resulting YAML.

In PR #6508, these nodes were gated and dropped under the rationale that "a node whose tcp/http obfuscation Clash cannot express was emitted anyway ... so drop it".

While this restriction makes sense for discontinued clients like Clash for Windows (which lack built-in obfs), Mihomo (Clash.Meta) natively supports simple-obfs out of the box via plugin: obfs and plugin-opts: {mode: http, host: ...} without requiring any external obfs-local executable.

Because 3x-ui already maintains a dedicated dual-endpoint architecture separating modern Mihomo (/mihomo/) from legacy clients (/clash-legacy/), enforcing this legacy Clash limitation at the lowest level (applyTransport) unnecessarily strips functional nodes from Mihomo users.

How to reproduce the problem

  1. Create a new Shadowsocks inbound (e.g., method 2022-blake3-aes-128-gcm or aes-256-gcm).
  2. Set Transport (network) to tcp.
  3. In TCP Settings, configure Header Type to http with a fake host (e.g., gateway.icloud.com).
  4. Enable the Clash/Mihomo subscription service.
  5. Fetch the subscription via the Mihomo endpoint (/mihomo/<sub-id>).
  6. Observe that the Shadowsocks node is completely missing from the proxies list.

Expected behavior

For Mihomo endpoints (/mihomo/<sub-id>), the Shadowsocks node should be exported with its TCP HTTP header mapped to Mihomo's built-in plugin: obfs, like so:

- name: SS-HTTP-Obfs
  type: ss
  server: example.com
  port: 8088
  cipher: 2022-blake3-aes-128-gcm # or aes-256-gcm
  password: <server-key>:<client-key>
  udp: true
  plugin: obfs
  plugin-opts:
    mode: http
    host: gateway.icloud.com

### Actual behavior

The proxy is silently dropped in `buildProxy()` because `applyTransport()` returns `false` when it encounters `typeStr != "" && typeStr != "none"`, which was pinned with `wantDropped: true` in `internal/sub/clash_external_shadowsocks_test.go`.

### Relevant logs

```shell
### Root Cause:
In `internal/sub/clash_service.go`:

1. In `buildProxy()` (line 428), `applyTransport()` is evaluated before the protocol-specific switch:

if !s.applyTransport(proxy, network, stream) {
    return nil
}

2. In `applyTransport()` (line 1053), all non-none TCP headers are hard-coded to return false:

if typeStr != "" && typeStr != "none" {
    return false
}


This enforces legacy Clash's lack of TCP header support globally, preventing Shadowsocks from reaching its protocol block where plugin: obfs could be generated for Mihomo.

Screenshots

  1. In buildProxy(), allow Shadowsocks with TCP HTTP headers to bypass the applyTransport drop.
  2. In the case model.Shadowsocks: block, map tcpSettings.header to proxy["plugin"] = "obfs" and proxy["plugin-opts"] = map[string]any{"mode": "http", "host": obfsHost} (matching what genShadowsocksLink already does for SIP002 URIs).
  3. If necessary, let legacyClashProxies() filter this out only when requested via /clash-legacy/.

3x-ui version

3.9.0

Xray-core version

26.9.30

How did you install 3x-ui?

install.sh script

Operating system

Debian 13

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?

None

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 @EmmaHermione on GitHub (Oct 5, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6735 ### Describe the bug When generating Clash/Mihomo subscriptions (`/mihomo/<sub-id>` or `/clash/<sub-id>`), any Shadowsocks inbound (both legacy AEAD and 2022 methods) configured with TCP HTTP obfuscation (`network: tcp` with `header.type: http`) is completely omitted from the resulting YAML. In PR #6508, these nodes were gated and dropped under the rationale that *"a node whose tcp/http obfuscation Clash cannot express was emitted anyway ... so drop it"*. While this restriction makes sense for discontinued clients like Clash for Windows (which lack built-in obfs), **Mihomo (Clash.Meta) natively supports simple-obfs out of the box** via `plugin: obfs` and `plugin-opts: {mode: http, host: ...}` without requiring any external `obfs-local` executable. Because 3x-ui already maintains a dedicated dual-endpoint architecture separating modern Mihomo (`/mihomo/`) from legacy clients (`/clash-legacy/`), enforcing this legacy Clash limitation at the lowest level (`applyTransport`) unnecessarily strips functional nodes from Mihomo users. ### How to reproduce the problem 1. Create a new Shadowsocks inbound (e.g., method `2022-blake3-aes-128-gcm` or `aes-256-gcm`). 2. Set Transport (`network`) to `tcp`. 3. In TCP Settings, configure Header Type to `http` with a fake host (e.g., `gateway.icloud.com`). 4. Enable the Clash/Mihomo subscription service. 5. Fetch the subscription via the Mihomo endpoint (`/mihomo/<sub-id>`). 6. Observe that the Shadowsocks node is completely missing from the `proxies` list. ### Expected behavior For Mihomo endpoints (`/mihomo/<sub-id>`), the Shadowsocks node should be exported with its TCP HTTP header mapped to Mihomo's built-in `plugin: obfs`, like so: ```yaml - name: SS-HTTP-Obfs type: ss server: example.com port: 8088 cipher: 2022-blake3-aes-128-gcm # or aes-256-gcm password: <server-key>:<client-key> udp: true plugin: obfs plugin-opts: mode: http host: gateway.icloud.com ### Actual behavior The proxy is silently dropped in `buildProxy()` because `applyTransport()` returns `false` when it encounters `typeStr != "" && typeStr != "none"`, which was pinned with `wantDropped: true` in `internal/sub/clash_external_shadowsocks_test.go`. ### Relevant logs ```shell ### Root Cause: In `internal/sub/clash_service.go`: 1. In `buildProxy()` (line 428), `applyTransport()` is evaluated before the protocol-specific switch: if !s.applyTransport(proxy, network, stream) { return nil } 2. In `applyTransport()` (line 1053), all non-none TCP headers are hard-coded to return false: if typeStr != "" && typeStr != "none" { return false } This enforces legacy Clash's lack of TCP header support globally, preventing Shadowsocks from reaching its protocol block where plugin: obfs could be generated for Mihomo. ``` ### Screenshots 1. In buildProxy(), allow Shadowsocks with TCP HTTP headers to bypass the applyTransport drop. 2. In the case model.Shadowsocks: block, map tcpSettings.header to proxy["plugin"] = "obfs" and proxy["plugin-opts"] = map[string]any{"mode": "http", "host": obfsHost} (matching what genShadowsocksLink already does for SIP002 URIs). 3. If necessary, let legacyClashProxies() filter this out only when requested via /clash-legacy/. ### 3x-ui version 3.9.0 ### Xray-core version 26.9.30 ### How did you install 3x-ui? install.sh script ### Operating system Debian 13 ### 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? None ### 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:39:59 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Oct 5, 2026):

You've read the code correctly: on 3.9.0, and still on the default branch, the Clash/Mihomo subscription leaves out a Shadowsocks inbound that uses a TCP http header. That is a deliberate gate with a test pinning it, not a regression. What you're asking for, mapping the header to Mihomo's built-in plugin: obfs, is a new export mapping, so I've filed this as a feature request.

What the code does

buildProxy runs the transport check before the protocol switch, so the model.Shadowsocks case never runs for such a node (internal/sub/clash_service.go:428):

if !s.applyTransport(proxy, network, stream) {
    return nil
}

and applyTransport rejects every non-none TCP header (internal/sub/clash_service.go:1052-1055):

typeStr, _ := header["type"].(string)
if typeStr != "" && typeStr != "none" {
    return false
}

TestApplyTransport_TCPHeader (internal/sub/clash_service_test.go:211-227) pins this on purpose: "tcp + non-none (http) header is not representable in clash and must be rejected". PR #6508 (ff1a6c3c) then routed external ss:// links through the same gate. Its description gives the reason: "mihomo cannot express an xray tcpSettings.header.type=http on a shadowsocks proxy". The check itself is older. git log -S traces it back to the file move in 41645255 (#5167).

Why the request has a basis in the repo (for the maintainer)

That reason conflicts with the panel's own share-link path. For this exact inbound, genShadowsocksLink already writes the header as simple-obfs (internal/sub/service.go:1372-1381):

// SIP002 clients (v2rayN) ignore the xray-native type/headerType/host/path
// params and only read `plugin`. Re-encode a TCP http header as obfs-local so
...
params["plugin"] = "obfs-local;obfs=http;obfs-host=" + host

TestShadowsocksTcpHttpHeaderUsesObfsLocalPlugin (internal/sub/characterization_test.go:180) pins this. So the plain-link subscription already treats simple-obfs http as the client-side match for Xray's TCP http header. The Clash/Mihomo path refuses the same node.

Other points that matter for an implementation:

  • The legacy filter already lets plugin and plugin-opts through on ss proxies (internal/sub/clash_service.go:232), so /clash-legacy/ would pass the new fields on unless they are filtered there.
  • The external-link path (internal/sub/clash_external.go:97-98) uses the same applyTransport, so any change applies to both paths.
  • TestApplyTransport_TCPHeader and the dropped-node expectations in clash_external_quota_test.go would need to change to match.

What I could not confirm

I can't run Xray or Mihomo here. So it is my inference, not a tested result, that Mihomo's built-in obfs HTTP request (fixed GET / with its own headers) gets through Xray's server-side TCP http header check when the inbound sets a custom request path, method or extra headers. A one-off test against an inbound with a non-/ path would settle that.

Workaround until then: use the plain subscription or the inbound's ss:// share link, which already carries plugin=obfs-local;obfs=http;obfs-host=…. Or switch the inbound's TCP header to none / use another transport if it has to appear in the Mihomo YAML.

I changed the title from "[Bug]: Shadowsocks with TCP HTTP obfs is dropped from Mihomo subscription instead of mapping to native 'plugin: obfs'" to make clear this is a feature request.

Verdict: Feature request

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

<!-- gh-comment-id:5990208291 --> @github-actions[bot] commented on GitHub (Oct 5, 2026): You've read the code correctly: on 3.9.0, and still on the default branch, the Clash/Mihomo subscription leaves out a Shadowsocks inbound that uses a TCP `http` header. That is a deliberate gate with a test pinning it, not a regression. What you're asking for, mapping the header to Mihomo's built-in `plugin: obfs`, is a new export mapping, so I've filed this as a feature request. **What the code does** `buildProxy` runs the transport check before the protocol switch, so the `model.Shadowsocks` case never runs for such a node (`internal/sub/clash_service.go:428`): ```go if !s.applyTransport(proxy, network, stream) { return nil } ``` and `applyTransport` rejects every non-`none` TCP header (`internal/sub/clash_service.go:1052-1055`): ```go typeStr, _ := header["type"].(string) if typeStr != "" && typeStr != "none" { return false } ``` `TestApplyTransport_TCPHeader` (`internal/sub/clash_service_test.go:211-227`) pins this on purpose: *"tcp + non-none (http) header is not representable in clash and must be rejected"*. PR #6508 (`ff1a6c3c`) then routed external `ss://` links through the same gate. Its description gives the reason: "mihomo cannot express an xray `tcpSettings.header.type=http` on a shadowsocks proxy". The check itself is older. `git log -S` traces it back to the file move in `41645255` (#5167). **Why the request has a basis in the repo (for the maintainer)** That reason conflicts with the panel's own share-link path. For this exact inbound, `genShadowsocksLink` already writes the header as simple-obfs (`internal/sub/service.go:1372-1381`): ```go // SIP002 clients (v2rayN) ignore the xray-native type/headerType/host/path // params and only read `plugin`. Re-encode a TCP http header as obfs-local so ... params["plugin"] = "obfs-local;obfs=http;obfs-host=" + host ``` `TestShadowsocksTcpHttpHeaderUsesObfsLocalPlugin` (`internal/sub/characterization_test.go:180`) pins this. So the plain-link subscription already treats simple-obfs `http` as the client-side match for Xray's TCP `http` header. The Clash/Mihomo path refuses the same node. Other points that matter for an implementation: - The legacy filter already lets `plugin` and `plugin-opts` through on `ss` proxies (`internal/sub/clash_service.go:232`), so `/clash-legacy/` would pass the new fields on unless they are filtered there. - The external-link path (`internal/sub/clash_external.go:97-98`) uses the same `applyTransport`, so any change applies to both paths. - `TestApplyTransport_TCPHeader` and the dropped-node expectations in `clash_external_quota_test.go` would need to change to match. **What I could not confirm** I can't run Xray or Mihomo here. So it is my inference, not a tested result, that Mihomo's built-in obfs HTTP request (fixed `GET /` with its own headers) gets through Xray's server-side TCP `http` header check when the inbound sets a custom request path, method or extra headers. A one-off test against an inbound with a non-`/` path would settle that. **Workaround until then:** use the plain subscription or the inbound's `ss://` share link, which already carries `plugin=obfs-local;obfs=http;obfs-host=…`. Or switch the inbound's TCP header to `none` / use another transport if it has to appear in the Mihomo YAML. I changed the title from "[Bug]: Shadowsocks with TCP HTTP obfs is dropped from Mihomo subscription instead of mapping to native 'plugin: obfs'" to make clear this is a feature request. Verdict: Feature request *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
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#4486
No description provided.