Ver código fonte

feat: allow set bypass without using default value

MystiPanda 11 meses atrás
pai
commit
7b9bf9e552

+ 5 - 0
src-tauri/src/config/verge.rs

@@ -75,6 +75,9 @@ pub struct IVerge {
     /// enable proxy guard
     pub enable_proxy_guard: Option<bool>,
 
+    /// always use default bypass
+    pub use_default_bypass: Option<bool>,
+
     /// set system proxy bypass
     pub system_proxy_bypass: Option<String>,
 
@@ -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);

+ 14 - 6
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,<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

+ 17 - 0
src/components/setting/mods/sysproxy-viewer.tsx

@@ -49,6 +49,7 @@ export const SysproxyViewer = forwardRef<DialogRef>((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<DialogRef>((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<DialogRef>((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<DialogRef>((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<DialogRef>((props, ref) => {
             }}
           />
         </ListItem>
+        {!value.pac && (
+          <ListItem sx={{ padding: "5px 2px" }}>
+            <ListItemText primary={t("Always use Default Bypass")} />
+            <Switch
+              edge="end"
+              disabled={!enabled}
+              checked={value.use_default}
+              onChange={(_, e) => setValue((v) => ({ ...v, use_default: e }))}
+            />
+          </ListItem>
+        )}
         {!value.pac && (
           <>
             <ListItemText primary={t("Proxy Bypass")} />

+ 1 - 0
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",

+ 1 - 0
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",

+ 1 - 0
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",

+ 1 - 0
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模式",

+ 1 - 0
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[];