Skip to content

Commit 91c82ba

Browse files
committed
xhttp extra导入导出时兼容xray格式
1 parent e591f9f commit 91c82ba

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

‎app/src/main/java/io/nekohasekai/sagernet/fmt/v2ray/XhttpExtraConverter.kt‎

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,23 @@ object XhttpExtraConverter {
8484
singBoxDown.put("tls", tls)
8585
}
8686

87-
xrayDown.optJSONObject("xhttpSettings")?.optJSONObject("extra")?.let { extraXmux ->
88-
val downXmux = JSONObject()
89-
convertField(extraXmux, downXmux, "maxConcurrency", "max_concurrency")
90-
convertField(extraXmux, downXmux, "maxConnections", "max_connections")
91-
convertField(extraXmux, downXmux, "cMaxReuseTimes", "c_max_reuse_times")
92-
convertField(extraXmux, downXmux, "hMaxRequestTimes", "h_max_request_times")
93-
convertField(extraXmux, downXmux, "hMaxReusableSecs", "h_max_reusable_secs")
94-
convertField(extraXmux, downXmux, "hKeepAlivePeriod", "h_keep_alive_period")
95-
if (downXmux.length() > 0) singBoxDown.put("xmux", downXmux)
96-
97-
convertField(extraXmux, singBoxDown, "xPaddingBytes", "x_padding_bytes")
98-
convertField(extraXmux, singBoxDown, "scMaxEachPostBytes", "sc_max_each_post_bytes")
99-
convertField(extraXmux, singBoxDown, "scMinPostsIntervalMs", "sc_min_posts_interval_ms")
100-
convertField(extraXmux, singBoxDown, "noGRPCHeader", "no_grpc_header")
87+
xrayDown.optJSONObject("xhttpSettings")?.optJSONObject("extra")?.let { extra ->
88+
if (extra.has("xmux")) {
89+
val xrayXmux = extra.getJSONObject("xmux")
90+
val downXmux = JSONObject()
91+
convertField(xrayXmux, downXmux, "maxConcurrency", "max_concurrency")
92+
convertField(xrayXmux, downXmux, "maxConnections", "max_connections")
93+
convertField(xrayXmux, downXmux, "cMaxReuseTimes", "c_max_reuse_times")
94+
convertField(xrayXmux, downXmux, "hMaxRequestTimes", "h_max_request_times")
95+
convertField(xrayXmux, downXmux, "hMaxReusableSecs", "h_max_reusable_secs")
96+
convertField(xrayXmux, downXmux, "hKeepAlivePeriod", "h_keep_alive_period")
97+
if (downXmux.length() > 0) singBoxDown.put("xmux", downXmux)
98+
}
99+
100+
convertField(extra, singBoxDown, "xPaddingBytes", "x_padding_bytes")
101+
convertField(extra, singBoxDown, "scMaxEachPostBytes", "sc_max_each_post_bytes")
102+
convertField(extra, singBoxDown, "scMinPostsIntervalMs", "sc_min_posts_interval_ms")
103+
convertField(extra, singBoxDown, "noGRPCHeader", "no_grpc_header")
101104
}
102105

103106
if (singBoxDown.length() > 0) singBox.put("download", singBoxDown)

0 commit comments

Comments
 (0)