mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-28 07:14:40 +08:00
fix: unexpected port in use error when change ports
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
- 修复 Windows 下系统主题同步问题
|
||||
- 修复 URL Schemes 无法正常导入
|
||||
- 修复 Linux 下无法安装 TUN 服务
|
||||
- 修复可能的端口被占用误报
|
||||
|
||||
<details>
|
||||
<summary><strong> ✨ 新增功能 </strong></summary>
|
||||
|
||||
@@ -112,6 +112,7 @@ export const ClashPortViewer = forwardRef<ClashPortViewerRef>((_, ref) => {
|
||||
close: () => setOpen(false),
|
||||
}));
|
||||
|
||||
// TODO 减少代码复杂度,性能开支
|
||||
const onSave = useLockFn(async () => {
|
||||
// 端口冲突检测
|
||||
const portList = [
|
||||
@@ -140,14 +141,26 @@ export const ClashPortViewer = forwardRef<ClashPortViewerRef>((_, ref) => {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const port of portList) {
|
||||
const original = originalPortsRef.current;
|
||||
const changedPorts: number[] = [];
|
||||
|
||||
if (mixedPort !== original?.mixedPort) changedPorts.push(mixedPort);
|
||||
if (socksEnabled && socksPort !== original?.socksPort)
|
||||
changedPorts.push(socksPort);
|
||||
if (httpEnabled && httpPort !== original?.httpPort)
|
||||
changedPorts.push(httpPort);
|
||||
if (redirEnabled && redirPort !== original?.redirPort)
|
||||
changedPorts.push(redirPort);
|
||||
if (tproxyEnabled && tproxyPort !== original?.tproxyPort)
|
||||
changedPorts.push(tproxyPort);
|
||||
|
||||
for (const port of changedPorts) {
|
||||
try {
|
||||
const inUse = await isPortInUse(port);
|
||||
if (inUse) {
|
||||
showNotice.error("settings.modals.clashPort.messages.portInUse", {
|
||||
port,
|
||||
});
|
||||
const original = originalPortsRef.current;
|
||||
if (original) {
|
||||
setMixedPort(original.mixedPort);
|
||||
setSocksPort(original.socksPort);
|
||||
@@ -201,7 +214,7 @@ export const ClashPortViewer = forwardRef<ClashPortViewerRef>((_, ref) => {
|
||||
};
|
||||
|
||||
// 提交保存请求
|
||||
await saveSettings({ clashConfig, vergeConfig });
|
||||
saveSettings({ clashConfig, vergeConfig });
|
||||
});
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user