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:
1 parent
fdacd58ed0
commit
e3fa861571
1 file changed
+7
-1
@@ -113,8 +113,14 @@ object CoreConfigManager {
|
||||
}
|
||||
} else {
|
||||
json.remove("stats")
|
||||
// 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()) {
|
||||
return JsonUtil.toJsonPretty(json)?.let { ConfigResult(true, configContext.guid, it) } ?: result
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user