diff --git a/src-tauri/src/config/verge.rs b/src-tauri/src/config/verge.rs index be454c5d..a7f8827c 100644 --- a/src-tauri/src/config/verge.rs +++ b/src-tauri/src/config/verge.rs @@ -75,6 +75,9 @@ pub struct IVerge { /// enable proxy guard pub enable_proxy_guard: Option, + /// always use default bypass + pub use_default_bypass: Option, + /// set system proxy bypass pub system_proxy_bypass: Option, @@ -235,6 +238,7 @@ impl IVerge { verge_port: Some(7899), verge_http_enabled: Some(true), enable_proxy_guard: Some(false), + use_default_bypass: Some(true), proxy_guard_duration: Some(30), auto_close_connection: Some(true), auto_check_update: Some(true), @@ -297,6 +301,7 @@ impl IVerge { patch!(verge_http_enabled); patch!(enable_system_proxy); patch!(enable_proxy_guard); + patch!(use_default_bypass); patch!(system_proxy_bypass); patch!(proxy_guard_duration); patch!(proxy_auto_config); diff --git a/src-tauri/src/core/sysopt.rs b/src-tauri/src/core/sysopt.rs index a5a6a806..35ed33a8 100644 --- a/src-tauri/src/core/sysopt.rs +++ b/src-tauri/src/core/sysopt.rs @@ -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,"; 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 diff --git a/src/components/setting/mods/sysproxy-viewer.tsx b/src/components/setting/mods/sysproxy-viewer.tsx index d5da90fb..8981477b 100644 --- a/src/components/setting/mods/sysproxy-viewer.tsx +++ b/src/components/setting/mods/sysproxy-viewer.tsx @@ -49,6 +49,7 @@ export const SysproxyViewer = forwardRef((props, ref) => { proxy_auto_config, pac_file_content, enable_proxy_guard, + use_default_bypass, system_proxy_bypass, proxy_guard_duration, } = verge ?? {}; @@ -57,6 +58,7 @@ export const SysproxyViewer = forwardRef((props, ref) => { guard: enable_proxy_guard, bypass: system_proxy_bypass, duration: proxy_guard_duration ?? 10, + use_default: use_default_bypass ?? true, pac: proxy_auto_config, pac_content: pac_file_content ?? DEFAULT_PAC, }); @@ -68,6 +70,7 @@ export const SysproxyViewer = forwardRef((props, ref) => { guard: enable_proxy_guard, bypass: system_proxy_bypass, duration: proxy_guard_duration ?? 10, + use_default: use_default_bypass ?? true, pac: proxy_auto_config, pac_content: pac_file_content ?? DEFAULT_PAC, }); @@ -97,6 +100,9 @@ export const SysproxyViewer = forwardRef((props, ref) => { if (value.pac !== proxy_auto_config) { patch.proxy_auto_config = value.pac; } + if (value.use_default !== use_default_bypass) { + patch.use_default_bypass = value.use_default; + } if (value.pac_content !== pac_file_content) { patch.pac_file_content = value.pac_content; } @@ -197,6 +203,17 @@ export const SysproxyViewer = forwardRef((props, ref) => { }} /> + {!value.pac && ( + + + setValue((v) => ({ ...v, use_default: e }))} + /> + + )} {!value.pac && ( <> diff --git a/src/locales/en.json b/src/locales/en.json index 38d8b838..bf4da6ab 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -151,6 +151,7 @@ "Proxy Guard": "Proxy Guard", "Proxy Guard Info": "Enable to prevent other software from modifying the operating system's proxy settings", "Guard Duration": "Guard Duration", + "Always use Default Bypass": "Always use Default Bypass", "Proxy Bypass": "Proxy Bypass Settings: ", "Bypass": "Bypass: ", "Use PAC Mode": "Use PAC Mode", diff --git a/src/locales/fa.json b/src/locales/fa.json index c9bea1f9..e309a102 100644 --- a/src/locales/fa.json +++ b/src/locales/fa.json @@ -141,6 +141,7 @@ "Proxy Guard": "محافظ پراکسی", "Proxy Guard Info": "امکان جلوگیری از نرم‌افزارهای دیگر از تغییر تنظیمات پروکسی سیستم عامل را فعال کنید", "Guard Duration": "مدت محافظت", + "Always use Default Bypass": "همیشه از دور زدن پیش‌فرض استفاده کنید", "Proxy Bypass": "دور زدن پراکسی: ", "Bypass": "دور زدن: ", "Use PAC Mode": "استفاده از حالت PAC", diff --git a/src/locales/ru.json b/src/locales/ru.json index dee452cd..5ebcf7d0 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -141,6 +141,7 @@ "Proxy Guard": "Защита прокси", "Proxy Guard Info": "Включите эту функцию чтобы предотвратить изменение настроек прокси-сервера операционной системы другим программным обеспечением", "Guard Duration": "Период защиты", + "Always use Default Bypass": "Всегда использовать стандартное обходное решение", "Proxy Bypass": "Игнорирование прокси: ", "Bypass": "Игнорирование: ", "Use PAC Mode": "Используйте режим PAC", diff --git a/src/locales/zh.json b/src/locales/zh.json index 24042d76..292565ed 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -151,6 +151,7 @@ "Proxy Guard": "系统代理守卫", "Proxy Guard Info": "开启以防止其他软件修改操作系统的代理设置", "Guard Duration": "代理守卫间隔", + "Always use Default Bypass": "始终使用默认绕过", "Proxy Bypass": "代理绕过设置:", "Bypass": "当前绕过:", "Use PAC Mode": "使用PAC模式", diff --git a/src/services/types.d.ts b/src/services/types.d.ts index b5fe3615..35a3f3c5 100644 --- a/src/services/types.d.ts +++ b/src/services/types.d.ts @@ -239,6 +239,7 @@ interface IVergeConfig { verge_socks_enabled?: boolean; verge_http_enabled?: boolean; enable_proxy_guard?: boolean; + use_default_bypass?: boolean; proxy_guard_duration?: number; system_proxy_bypass?: string; web_ui_list?: string[];