mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-04 16:47:33 +08:00
feat: add bypass check feature (#2272)
This commit is contained in:
parent
f400f900e6
commit
c71e18e97e
@ -1,7 +1,13 @@
|
||||
import { forwardRef, useImperativeHandle, useMemo, useState } from "react";
|
||||
import { useLockFn } from "ahooks";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { BaseDialog, DialogRef, Notice, Switch } from "@/components/base";
|
||||
import { BaseFieldset } from "@/components/base/base-fieldset";
|
||||
import { TooltipIcon } from "@/components/base/base-tooltip-icon";
|
||||
import { EditorViewer } from "@/components/profile/editor-viewer";
|
||||
import { useVerge } from "@/hooks/use-verge";
|
||||
import { getAutotemProxy, getSystemProxy } from "@/services/cmds";
|
||||
import getSystem from "@/utils/get-system";
|
||||
import { EditRounded } from "@mui/icons-material";
|
||||
import {
|
||||
Button,
|
||||
InputAdornment,
|
||||
List,
|
||||
ListItem,
|
||||
@ -9,16 +15,10 @@ import {
|
||||
styled,
|
||||
TextField,
|
||||
Typography,
|
||||
Button,
|
||||
} from "@mui/material";
|
||||
import { useVerge } from "@/hooks/use-verge";
|
||||
import { getSystemProxy, getAutotemProxy } from "@/services/cmds";
|
||||
import { BaseDialog, DialogRef, Notice, Switch } from "@/components/base";
|
||||
import { EditRounded } from "@mui/icons-material";
|
||||
import { EditorViewer } from "@/components/profile/editor-viewer";
|
||||
import { BaseFieldset } from "@/components/base/base-fieldset";
|
||||
import getSystem from "@/utils/get-system";
|
||||
import { TooltipIcon } from "@/components/base/base-tooltip-icon";
|
||||
import { useLockFn } from "ahooks";
|
||||
import { forwardRef, useImperativeHandle, useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
const DEFAULT_PAC = `function FindProxyForURL(url, host) {
|
||||
return "PROXY 127.0.0.1:%mixed-port%; SOCKS5 127.0.0.1:%mixed-port%; DIRECT;";
|
||||
}`;
|
||||
@ -76,6 +76,7 @@ export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
proxy_auto_config,
|
||||
pac_file_content,
|
||||
enable_proxy_guard,
|
||||
enable_bypass_check,
|
||||
use_default_bypass,
|
||||
system_proxy_bypass,
|
||||
proxy_guard_duration,
|
||||
@ -84,6 +85,7 @@ export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
const [value, setValue] = useState({
|
||||
guard: enable_proxy_guard,
|
||||
bypass: system_proxy_bypass,
|
||||
bypass_check: enable_bypass_check ?? true,
|
||||
duration: proxy_guard_duration ?? 10,
|
||||
use_default: use_default_bypass ?? true,
|
||||
pac: proxy_auto_config,
|
||||
@ -96,6 +98,7 @@ export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
setValue({
|
||||
guard: enable_proxy_guard,
|
||||
bypass: system_proxy_bypass,
|
||||
bypass_check: enable_bypass_check ?? true,
|
||||
duration: proxy_guard_duration ?? 10,
|
||||
use_default: use_default_bypass ?? true,
|
||||
pac: proxy_auto_config,
|
||||
@ -124,6 +127,9 @@ export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
if (value.bypass !== system_proxy_bypass) {
|
||||
patch.system_proxy_bypass = value.bypass;
|
||||
}
|
||||
if (value.bypass_check !== enable_bypass_check) {
|
||||
patch.enable_bypass_check = value.bypass_check;
|
||||
}
|
||||
if (value.pac !== proxy_auto_config) {
|
||||
patch.proxy_auto_config = value.pac;
|
||||
}
|
||||
@ -133,7 +139,7 @@ export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
if (value.pac_content !== pac_file_content) {
|
||||
patch.pac_file_content = value.pac_content;
|
||||
}
|
||||
if (value.bypass && !validReg.test(value.bypass)) {
|
||||
if (value.bypass && value.bypass_check && !validReg.test(value.bypass)) {
|
||||
Notice.error(t("Invalid Bypass Format"));
|
||||
return;
|
||||
}
|
||||
@ -242,12 +248,27 @@ export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
/>
|
||||
</ListItem>
|
||||
)}
|
||||
{!value.pac && (
|
||||
<ListItem sx={{ padding: "5px 2px" }}>
|
||||
<ListItemText primary={t("Use Bypass Check")} />
|
||||
<Switch
|
||||
edge="end"
|
||||
disabled={!enabled}
|
||||
checked={value.bypass_check}
|
||||
onChange={(_, e) => setValue((v) => ({ ...v, bypass_check: e }))}
|
||||
/>
|
||||
</ListItem>
|
||||
)}
|
||||
{!value.pac && (
|
||||
<>
|
||||
<ListItemText primary={t("Proxy Bypass")} />
|
||||
<TextField
|
||||
autoComplete="new-password"
|
||||
error={value.bypass ? !validReg.test(value.bypass) : false}
|
||||
error={
|
||||
value.bypass && value.bypass_check
|
||||
? !validReg.test(value.bypass)
|
||||
: false
|
||||
}
|
||||
disabled={!enabled}
|
||||
size="small"
|
||||
multiline
|
||||
|
@ -229,6 +229,7 @@
|
||||
"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",
|
||||
"Use Bypass Check": "Use Bypass Check",
|
||||
"Proxy Bypass": "Proxy Bypass Settings: ",
|
||||
"Bypass": "Bypass: ",
|
||||
"Use PAC Mode": "Use PAC Mode",
|
||||
|
@ -229,6 +229,7 @@
|
||||
"Proxy Guard Info": "امکان جلوگیری از نرمافزارهای دیگر از تغییر تنظیمات پروکسی سیستم عامل را فعال کنید",
|
||||
"Guard Duration": "مدت محافظت",
|
||||
"Always use Default Bypass": "همیشه از دور زدن پیشفرض استفاده کنید",
|
||||
"Use Bypass Check": "استخدم التحقق من التحايل",
|
||||
"Proxy Bypass": "دور زدن پراکسی: ",
|
||||
"Bypass": "دور زدن: ",
|
||||
"Use PAC Mode": "استفاده از حالت PAC",
|
||||
|
@ -229,6 +229,7 @@
|
||||
"Proxy Guard Info": "Включите эту функцию чтобы предотвратить изменение настроек прокси-сервера операционной системы другим программным обеспечением",
|
||||
"Guard Duration": "Период защиты",
|
||||
"Always use Default Bypass": "Всегда использовать стандартное обходное решение",
|
||||
"Use Bypass Check": "Используйте проверку обхода",
|
||||
"Proxy Bypass": "Игнорирование прокси: ",
|
||||
"Bypass": "Игнорирование: ",
|
||||
"Use PAC Mode": "Используйте режим PAC",
|
||||
|
@ -229,6 +229,7 @@
|
||||
"Proxy Guard Info": "开启以防止其他软件修改操作系统的代理设置",
|
||||
"Guard Duration": "代理守卫间隔",
|
||||
"Always use Default Bypass": "始终使用默认绕过",
|
||||
"Use Bypass Check": "启用代理绕过检查",
|
||||
"Proxy Bypass": "代理绕过设置:",
|
||||
"Bypass": "当前绕过:",
|
||||
"Use PAC Mode": "使用PAC模式",
|
||||
|
1
src/services/types.d.ts
vendored
1
src/services/types.d.ts
vendored
@ -723,6 +723,7 @@ interface IVergeConfig {
|
||||
verge_socks_enabled?: boolean;
|
||||
verge_http_enabled?: boolean;
|
||||
enable_proxy_guard?: boolean;
|
||||
enable_bypass_check?: boolean;
|
||||
use_default_bypass?: boolean;
|
||||
proxy_guard_duration?: number;
|
||||
system_proxy_bypass?: string;
|
||||
|
Loading…
x
Reference in New Issue
Block a user