From 20a03cde93c13fdb28a3d265195392677e7f4ba5 Mon Sep 17 00:00:00 2001 From: lrisora <43085437+lrisora@users.noreply.github.com> Date: Wed, 5 May 2021 20:47:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=8D=E6=94=B9=E5=8F=98?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E4=BB=A3=E7=90=86=E6=97=B6=E7=9A=84=E9=80=80?= =?UTF-8?q?=E5=87=BA=E8=A1=8C=E4=B8=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- v2rayN/v2rayN/Forms/MainForm.cs | 1 + v2rayN/v2rayN/HttpProxyHandler/HttpProxyHandle.cs | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs index 08783e41..db6d66da 100644 --- a/v2rayN/v2rayN/Forms/MainForm.cs +++ b/v2rayN/v2rayN/Forms/MainForm.cs @@ -36,6 +36,7 @@ namespace v2rayN.Forms v2rayHandler.V2rayStop(); //HttpProxyHandle.CloseHttpAgent(config); + // 第二个bool参数指示此次UpdateSysProxy是否为退出 HttpProxyHandle.UpdateSysProxy(config, true); ConfigHandler.SaveConfig(ref config); diff --git a/v2rayN/v2rayN/HttpProxyHandler/HttpProxyHandle.cs b/v2rayN/v2rayN/HttpProxyHandler/HttpProxyHandle.cs index cab3c055..1a37ad30 100644 --- a/v2rayN/v2rayN/HttpProxyHandler/HttpProxyHandle.cs +++ b/v2rayN/v2rayN/HttpProxyHandler/HttpProxyHandle.cs @@ -147,11 +147,12 @@ namespace v2rayN.HttpProxyHandler Update(config, false); } - public static bool UpdateSysProxy(Config config, bool forceDisable) + public static bool UpdateSysProxy(Config config, bool isExit) { var type = config.sysProxyType; - if (forceDisable) + // 如果是程序退出那么自动配置系统代理的更新行为应当是清除 + if (isExit && type == ESysProxyType.ForcedChange) { type = ESysProxyType.ForcedClear; } @@ -170,6 +171,7 @@ namespace v2rayN.HttpProxyHandler } else if (type == ESysProxyType.ForcedClear) { + // 系统关机时这里无法复位成功,需要改 SysProxyHandle.ResetIEProxy(); } else if (type == ESysProxyType.Unchanged)