refactor(config): remove the unused runtime patch API

This commit is contained in:
Tunglies
2026-12-03 20:56:41 +08:00
parent 63000f39f5
commit 6cce982f58
3 changed files with 7 additions and 45 deletions
-37
View File
@@ -2,10 +2,6 @@ use serde_yaml_ng::{Mapping, Value};
use std::collections::{HashMap, HashSet};
use tristr::alias::String;
use clash_verge_config_render::use_keys;
const PATCH_CONFIG_INNER: [&str; 5] = ["allow-lan", "ipv6", "log-level", "unified-delay", "tunnels"];
#[derive(Default, Clone)]
pub struct IRuntime {
pub config: Option<Mapping>,
@@ -17,39 +13,6 @@ pub struct IRuntime {
}
impl IRuntime {
#[inline]
pub fn patch_config(&mut self, patch: &Mapping) {
let config = if let Some(config) = self.config.as_mut() {
config
} else {
return;
};
for key in PATCH_CONFIG_INNER.iter() {
if let Some(value) = patch.get(key) {
config.insert((*key).into(), value.clone());
}
}
let Some(patch_tun) = patch.get("tun") else {
return;
};
let tun_key = Value::from("tun");
if !matches!(config.get(&tun_key), Some(Value::Mapping(_))) {
config.insert(tun_key.clone(), Value::Mapping(Mapping::new()));
}
if let (Some(patch_tun_mapping), Some(Value::Mapping(tun))) = (patch_tun.as_mapping(), config.get_mut(&tun_key))
{
for key in use_keys(patch_tun_mapping) {
if let Some(value) = patch_tun_mapping.get(key.as_str()) {
tun.insert(Value::from(key.as_str()), value.clone());
}
}
}
}
/// Rebuilds `dialer-proxy` links from an ordered proxy chain, or removes them for `None`.
#[inline]
pub fn update_proxy_chain_config(&mut self, proxy_chain_config: Option<Value>) {