From 18d6e9390727a9e996f01c9524e32574eaf0db55 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Wed, 22 Mar 2023 13:59:55 +0800 Subject: [PATCH] Optimizing Subscription Update --- clashN/clashN/Handler/DownloadHandle.cs | 4 +++- clashN/clashN/Handler/UpdateHandle.cs | 26 ++++++++++++------------- clashN/clashN/clashN.csproj | 4 ++-- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/clashN/clashN/Handler/DownloadHandle.cs b/clashN/clashN/Handler/DownloadHandle.cs index d150a59..68ee082 100644 --- a/clashN/clashN/Handler/DownloadHandle.cs +++ b/clashN/clashN/Handler/DownloadHandle.cs @@ -75,9 +75,11 @@ namespace ClashN.Handler try { Utils.SetSecurityProtocol(LazyConfig.Instance.Config.EnableSecurityProtocolTls13); + var webProxy = GetWebProxy(blProxy); var client = new HttpClient(new SocketsHttpHandler() { - Proxy = GetWebProxy(blProxy) + Proxy = webProxy, + UseProxy = webProxy != null }); if (string.IsNullOrEmpty(userAgent)) diff --git a/clashN/clashN/Handler/UpdateHandle.cs b/clashN/clashN/Handler/UpdateHandle.cs index ce5f8ce..8a6e335 100644 --- a/clashN/clashN/Handler/UpdateHandle.cs +++ b/clashN/clashN/Handler/UpdateHandle.cs @@ -173,14 +173,14 @@ namespace ClashN.Handler Task.Run(async () => { //Turn off system proxy - bool bSysProxyType = false; - if (!blProxy && config.SysProxyType == SysProxyType.ForcedChange) - { - bSysProxyType = true; - config.SysProxyType = SysProxyType.ForcedClear; - SysProxyHandle.UpdateSysProxy(config, false); - Thread.Sleep(3000); - } + //bool bSysProxyType = false; + //if (!blProxy && config.SysProxyType == SysProxyType.ForcedChange) + //{ + // bSysProxyType = true; + // config.SysProxyType = SysProxyType.ForcedClear; + // SysProxyHandle.UpdateSysProxy(config, false); + // Thread.Sleep(3000); + //} if (profileItems == null) { @@ -280,11 +280,11 @@ namespace ClashN.Handler } //restore system proxy - if (bSysProxyType) - { - config.SysProxyType = SysProxyType.ForcedChange; - SysProxyHandle.UpdateSysProxy(config, false); - } + //if (bSysProxyType) + //{ + // config.SysProxyType = SysProxyType.ForcedChange; + // SysProxyHandle.UpdateSysProxy(config, false); + //} _updateFunc(true, $"{ResUI.MsgUpdateSubscriptionEnd}"); }); } diff --git a/clashN/clashN/clashN.csproj b/clashN/clashN/clashN.csproj index d96ff80..4013d7c 100644 --- a/clashN/clashN/clashN.csproj +++ b/clashN/clashN/clashN.csproj @@ -14,14 +14,14 @@ - + - +