From d3dbc11b1b4f9c436c0a5dc50c412d3e3f285d32 Mon Sep 17 00:00:00 2001 From: Ahao <108321411+Ahaohaohao@users.noreply.github.com> Date: Sun, 25 May 2025 17:05:08 +0800 Subject: [PATCH] modify the port detection range to prevent the use of system ports (#3587) Co-authored-by: Ahao <108321411+xuanyuan0408@users.noreply.github.com> --- UPDATELOG.md | 1 + src/hooks/use-clash.ts | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/UPDATELOG.md b/UPDATELOG.md index ec7d12c3c..6399bc2df 100644 --- a/UPDATELOG.md +++ b/UPDATELOG.md @@ -77,6 +77,7 @@ - 优化了保存机制,使用平滑函数,防止客户端卡死 - 优化端口设置退出和保存机制 - 强制为 Mihomo 配置补全并覆盖 external-controller-cors 字段,默认不允许跨域和仅本地请求,提升 cors 安全性,升级配置时自动覆盖 + - 修改 端口检测范围 (1111-65536) #### 移除了: - 窗口状态管理器 diff --git a/src/hooks/use-clash.ts b/src/hooks/use-clash.ts index e680a18ca..34b869c2a 100644 --- a/src/hooks/use-clash.ts +++ b/src/hooks/use-clash.ts @@ -71,8 +71,8 @@ export const useClashInfo = () => { if (patch["redir-port"]) { const port = patch["redir-port"]; - if (port < 1000) { - throw new Error("The port should not < 1000"); + if (port < 1111) { + throw new Error("The port should not < 1111"); } if (port > 65536) { throw new Error("The port should not > 65536"); @@ -81,8 +81,8 @@ export const useClashInfo = () => { if (patch["tproxy-port"]) { const port = patch["tproxy-port"]; - if (port < 1000) { - throw new Error("The port should not < 1000"); + if (port < 1111) { + throw new Error("The port should not < 1111"); } if (port > 65536) { throw new Error("The port should not > 65536"); @@ -91,8 +91,8 @@ export const useClashInfo = () => { if (patch["mixed-port"]) { const port = patch["mixed-port"]; - if (port < 1000) { - throw new Error("The port should not < 1000"); + if (port < 1111) { + throw new Error("The port should not < 1111"); } if (port > 65536) { throw new Error("The port should not > 65536"); @@ -101,8 +101,8 @@ export const useClashInfo = () => { if (patch["socks-port"]) { const port = patch["socks-port"]; - if (port < 1000) { - throw new Error("The port should not < 1000"); + if (port < 1111) { + throw new Error("The port should not < 1111"); } if (port > 65536) { throw new Error("The port should not > 65536"); @@ -111,8 +111,8 @@ export const useClashInfo = () => { if (patch["port"]) { const port = patch["port"]; - if (port < 1000) { - throw new Error("The port should not < 1000"); + if (port < 1111) { + throw new Error("The port should not < 1111"); } if (port > 65536) { throw new Error("The port should not > 65536");