fix: tun mode switch is not effective

This commit is contained in:
huzibaca 2024-10-24 02:16:28 +08:00
parent cc81b443be
commit 34af040c48
2 changed files with 3 additions and 5 deletions

View File

@ -259,9 +259,7 @@ pub async fn enhance() -> (Mapping, Vec<String>, HashMap<String, ResultLog>) {
}); });
} }
if enable_tun { config = use_tun(config, enable_tun).await;
config = use_tun(config).await;
}
config = use_sort(config); config = use_sort(config);
let mut exists_set = HashSet::new(); let mut exists_set = HashSet::new();

View File

@ -18,13 +18,13 @@ macro_rules! append {
}; };
} }
pub async fn use_tun(mut config: Mapping) -> Mapping { pub async fn use_tun(mut config: Mapping, enable: bool) -> Mapping {
let tun_key = Value::from("tun"); let tun_key = Value::from("tun");
let tun_val = config.get(&tun_key); let tun_val = config.get(&tun_key);
let mut tun_val = tun_val.map_or(Mapping::new(), |val| { let mut tun_val = tun_val.map_or(Mapping::new(), |val| {
val.as_mapping().cloned().unwrap_or(Mapping::new()) val.as_mapping().cloned().unwrap_or(Mapping::new())
}); });
revise!(tun_val, "enable", true); revise!(tun_val, "enable", enable);
revise!(config, "tun", tun_val); revise!(config, "tun", tun_val);
config config
} }