mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-15 09:35:00 +03:00
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:
@@ -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{}
|
||||
|
||||
Reference in New Issue
Block a user