feat: add unified delay

This commit is contained in:
huzibaca
2024-11-05 16:24:58 +08:00
parent ab7775e1ef
commit 2833718c90
15 changed files with 37 additions and 24 deletions

View File

@@ -55,6 +55,7 @@ impl IClashTemp {
map.insert("secret".into(), "".into());
map.insert("tun".into(), tun.into());
map.insert("external-controller-cors".into(), cors_map.into());
map.insert("unified-delay".into(), true.into());
Self(map)
}

View File

@@ -19,7 +19,7 @@ impl IRuntime {
// 这里只更改 allow-lan | ipv6 | log-level | tun
pub fn patch_config(&mut self, patch: Mapping) {
if let Some(config) = self.config.as_mut() {
["allow-lan", "ipv6", "log-level"]
["allow-lan", "ipv6", "log-level", "unified-delay"]
.into_iter()
.for_each(|key| {
if let Some(value) = patch.get(key).to_owned() {

View File

@@ -9,7 +9,7 @@ use std::collections::HashMap;
/// path 是绝对路径
pub async fn put_configs(path: &str) -> Result<()> {
let (url, headers) = clash_client_info()?;
let url = format!("{url}/configs");
let url = format!("{url}/configs?force=true");
let mut data = HashMap::new();
data.insert("path", path);

View File

@@ -1,7 +1,7 @@
use serde_yaml::{Mapping, Value};
use std::collections::HashSet;
pub const HANDLE_FIELDS: [&str; 11] = [
pub const HANDLE_FIELDS: [&str; 12] = [
"mode",
"redir-port",
"tproxy-port",
@@ -13,6 +13,7 @@ pub const HANDLE_FIELDS: [&str; 11] = [
"ipv6",
"external-controller",
"secret",
"unified-delay",
];
pub const DEFAULT_FIELDS: [&str; 5] = [

View File

@@ -119,14 +119,15 @@ pub async fn patch_clash(patch: Mapping) -> Result<()> {
Config::generate().await?;
CoreManager::global().restart_core().await?;
handle::Handle::refresh_clash();
}
} else {
if patch.get("mode").is_some() {
log_err!(handle::Handle::update_systray_part());
}
if patch.get("mode").is_some() {
log_err!(handle::Handle::update_systray_part());
Config::runtime().latest().patch_config(patch);
update_core_config(false).await?;
}
Config::runtime().latest().patch_config(patch);
<Result<()>>::Ok(())
};
match res {