fix(sub): emit Shadowsocks http-header links as SIP002 obfs-local plugin

v2rayN's SS parser only reads the SIP002 `plugin` query param; it ignores the
xray-native type/headerType/host/path, so an SS link with a TCP http header
imported as plain SS and failed to connect. Re-encode the http header as
`plugin=obfs-local;obfs=http;obfs-host=<host>`, which v2rayN maps to an
xray tcp/http-header outbound. Mirrored in the frontend link generator.

Note: v2rayN carries only the host and forces request path "/", so this matches
an inbound whose header path is "/" (the default); xray validates path, not host.
This commit is contained in:
MHSanaei
2026-06-17 14:11:25 +02:00
parent 5038fa1cec
commit 21e9b94bb4
3 changed files with 52 additions and 0 deletions
+12
View File
@@ -704,6 +704,18 @@ func (s *SubService) genShadowsocksLink(inbound *model.Inbound, email string) st
applyShareTLSParams(stream, params)
}
// 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
// they build a matching tcp/http outbound (v2rayN forces request path "/").
if streamNetwork == "tcp" && params["headerType"] == "http" {
host := params["host"]
delete(params, "type")
delete(params, "headerType")
delete(params, "host")
delete(params, "path")
params["plugin"] = "obfs-local;obfs=http;obfs-host=" + host
}
encPart := fmt.Sprintf("%s:%s", method, clients[clientIndex].Password)
if method[0] == '2' {
encPart = fmt.Sprintf("%s:%s:%s", method, inboundPassword, clients[clientIndex].Password)