mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-07-26 22:36:13 +00:00
fix(sub): wrap JSON-subscription SS/Trojan outbound in servers[] array
The flat top-level address/method/password form only parses on recent xray-core; older bundled cores (e.g. in v2rayN) reject it. Restore the standard "servers" array used through 2.9.x so the JSON subscription connects across all xray-core versions. VMess/VLESS keep the flat vnext fallback, which is long established in xray-core.
This commit is contained in:
@@ -425,16 +425,22 @@ func (s *SubJsonService) genServer(inbound *model.Inbound, streamSettings json_u
|
||||
}
|
||||
outbound.StreamSettings = streamSettings
|
||||
|
||||
settings := map[string]any{
|
||||
// Wrap the endpoint in a "servers" array (the standard Xray schema for
|
||||
// Shadowsocks/Trojan outbounds). The flat top-level form only parses on very
|
||||
// recent xray-core; older bundled cores (e.g. in v2rayN) reject it, so SS
|
||||
// links fail to connect. See genVnext/genVless for the VMess/VLESS shape.
|
||||
server := map[string]any{
|
||||
"address": serverData[0].Address,
|
||||
"port": serverData[0].Port,
|
||||
"password": serverData[0].Password,
|
||||
"level": 8,
|
||||
}
|
||||
if inbound.Protocol == model.Shadowsocks {
|
||||
settings["method"] = serverData[0].Method
|
||||
server["method"] = serverData[0].Method
|
||||
}
|
||||
outbound.Settings = map[string]any{
|
||||
"servers": []any{server},
|
||||
}
|
||||
outbound.Settings = settings
|
||||
|
||||
result, _ := json.MarshalIndent(outbound, "", " ")
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user