fix(link): read the XHTTP fields a vmess link carries inline (#6808)

A vmess link has no extra blob: the sub emitter writes the XHTTP extra
fields (session/seq/uplink placement, padding obfs, xmux, ...) at the
top level of the vmess JSON. The Go importer only read xPaddingBytes,
scMaxEachPostBytes and scMinPostsIntervalMs from there, so a vmess
XHTTP inbound with, for example, sessionIDPlacement=header or
xPaddingObfsMode came back from an outbound subscription or a client
external link as an outbound that cannot connect.

Read the same keys the TS importer already reads from vmess JSON,
including the pre-rename sessionPlacement/sessionKey aliases.
This commit is contained in:
Jay Hemnani
2026-10-14 19:04:35 +05:30
committed by GitHub
parent ff3f42ee2a
commit 6bd1b8676a
2 changed files with 69 additions and 2 deletions
+23 -2
View File
@@ -185,12 +185,18 @@ func parseVmess(link string) (*ParseResult, error) {
if m := getString(j, "mode", ""); m != "" {
xh["mode"] = m
}
// xhttp advanced keys are passed through if present in the json
for _, k := range []string{"xPaddingBytes", "scMaxEachPostBytes", "scMinPostsIntervalMs"} {
for _, k := range vmessXhttpKeys {
if v, ok := j[k]; ok {
xh[k] = v
}
}
for legacy, renamed := range xhttpLegacyAliases {
if _, ok := xh[renamed]; !ok {
if v, ok := j[legacy].(string); ok && v != "" {
xh[renamed] = v
}
}
}
case "tcp":
if getString(j, "type", "") == "http" {
stream["tcpSettings"] = map[string]any{
@@ -258,6 +264,21 @@ func parseVmess(link string) (*ParseResult, error) {
return &ParseResult{Outbound: ob, Identity: identity}, nil
}
// vmessXhttpKeys are the XHTTP fields a vmess link carries inline, where vless/trojan put them in extra.
var vmessXhttpKeys = []string{
"xPaddingBytes", "xPaddingObfsMode", "xPaddingKey", "xPaddingHeader", "xPaddingPlacement", "xPaddingMethod",
"sessionIDPlacement", "sessionIDKey", "sessionIDTable", "sessionIDLength",
"seqPlacement", "seqKey", "uplinkDataPlacement", "uplinkDataKey", "uplinkHTTPMethod", "uplinkChunkSize",
"scMaxEachPostBytes", "scMinPostsIntervalMs", "scMaxBufferedPosts", "scStreamUpServerSecs",
"serverMaxHeaderBytes", "noSSEHeader", "noGRPCHeader", "xmux", "downloadSettings", "headers",
}
// xhttpLegacyAliases maps the pre-rename session keys older links carry onto the current ones.
var xhttpLegacyAliases = map[string]string{
"sessionPlacement": "sessionIDPlacement",
"sessionKey": "sessionIDKey",
}
func vmessIdentity(j map[string]any) string {
// Remove ps (remark) for identity
core := map[string]any{}