feat: allow set bypass without using default value

This commit is contained in:
MystiPanda
2024-07-01 22:53:06 +08:00
parent c91ad1e016
commit 7b9bf9e552
8 changed files with 41 additions and 6 deletions

View File

@@ -42,8 +42,8 @@ static DEFAULT_BYPASS: &str =
"127.0.0.1,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12,localhost,*.local,*.crashlytics.com,<local>";
fn get_bypass() -> String {
let bypass = DEFAULT_BYPASS.to_string();
// let bypass = DEFAULT_BYPASS.to_string();
let use_default = Config::verge().latest().use_default_bypass.unwrap_or(true);
let res = {
let verge = Config::verge();
let verge = verge.latest();
@@ -55,15 +55,23 @@ fn get_bypass() -> String {
};
#[cfg(target_os = "windows")]
let bypass = if custom_bypass.is_empty() {
bypass
DEFAULT_BYPASS.to_string()
} else {
format!("{};{}", bypass, custom_bypass)
if use_default {
format!("{};{}", DEFAULT_BYPASS, custom_bypass)
} else {
custom_bypass
}
};
#[cfg(not(target_os = "windows"))]
let bypass = if custom_bypass.is_empty() {
bypass
DEFAULT_BYPASS.to_string()
} else {
format!("{},{}", bypass, custom_bypass)
if use_default {
format!("{},{}", DEFAULT_BYPASS, custom_bypass)
} else {
custom_bypass
}
};
bypass