fix: config file case close #18
This commit is contained in:
parent
392ecee3ff
commit
c73b354386
@ -328,7 +328,7 @@ impl Clash {
|
|||||||
if let Some(data) = result.data {
|
if let Some(data) = result.data {
|
||||||
// all of these can not be revised by script
|
// all of these can not be revised by script
|
||||||
// http/https/socks port should be under control
|
// http/https/socks port should be under control
|
||||||
let not_allow: Vec<Value> = vec![
|
let not_allow = vec![
|
||||||
"port",
|
"port",
|
||||||
"socks-port",
|
"socks-port",
|
||||||
"mixed-port",
|
"mixed-port",
|
||||||
@ -337,23 +337,29 @@ impl Clash {
|
|||||||
"external-controller",
|
"external-controller",
|
||||||
"secret",
|
"secret",
|
||||||
"log-level",
|
"log-level",
|
||||||
]
|
];
|
||||||
.iter()
|
|
||||||
.map(|&i| Value::from(i))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
for (key, value) in data.into_iter() {
|
for (key, value) in data.into_iter() {
|
||||||
if not_allow.iter().find(|&i| i == &key).is_none() {
|
key.as_str().map(|key_str| {
|
||||||
config.insert(key, value);
|
// change to lowercase
|
||||||
}
|
let mut key_str = String::from(key_str);
|
||||||
}
|
key_str.make_ascii_lowercase();
|
||||||
|
|
||||||
Self::_activate(info, config).unwrap();
|
// filter
|
||||||
|
if !not_allow.contains(&&*key_str) {
|
||||||
|
config.insert(Value::String(key_str), value);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!("profile enhanced status {}", result.status);
|
log::info!("profile enhanced status {}", result.status);
|
||||||
|
|
||||||
result.error.map(|error| log::error!("{error}"));
|
Self::_activate(info, config).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(error) = result.error {
|
||||||
|
log::error!("{error}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -566,13 +566,17 @@ impl Profiles {
|
|||||||
"rules",
|
"rules",
|
||||||
];
|
];
|
||||||
|
|
||||||
valid_keys.iter().for_each(|key| {
|
for (key, value) in def_config.into_iter() {
|
||||||
let key = Value::String(key.to_string());
|
key.as_str().map(|key_str| {
|
||||||
if def_config.contains_key(&key) {
|
// change to lowercase
|
||||||
let value = def_config[&key].clone();
|
let mut key_str = String::from(key_str);
|
||||||
new_config.insert(key, value);
|
key_str.make_ascii_lowercase();
|
||||||
|
|
||||||
|
if valid_keys.contains(&&*key_str) {
|
||||||
|
new_config.insert(Value::String(key_str), value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return Ok(new_config);
|
return Ok(new_config);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user