Do not remove policy levels when traffic statistics is disabled (#6146)

Disabling traffic statistics removed the whole policy section from the
generated config, including the levels block (uplinkOnly, downlinkOnly,
connIdle, handshake) from the template or from a user's custom config.
Only the stats-related policy.system block should be stripped; keep
policy.levels intact in both the unified and the custom config paths.
This commit is contained in:
patterniha authored and GitHub committed 2026-08-29 11:07:00 +08:00
1 parent fdacd58ed0
commit e3fa861571
1 file changed
+8 -2
@@ -113,7 +113,13 @@ object CoreConfigManager {
}
} else {
json.remove("stats")
json.remove("policy")
// Keep user-defined policy levels, only strip the stats-related system block
json.get("policy")?.takeIf { it.isJsonObject }?.asJsonObject?.let { policy ->
policy.remove("system")
if (policy.entrySet().isEmpty()) {
json.remove("policy")
}
}
}
if (!needTun()) {
@@ -709,7 +715,7 @@ object CoreConfigManager {
private fun applySpeedDisabled(v2rayConfig: V2rayConfig) {
if (MmkvManager.decodeSettingsBool(AppConfig.PREF_SPEED_ENABLED) != true) {
v2rayConfig.stats = null
v2rayConfig.policy = null
v2rayConfig.policy?.system = null
}
}