try to speed up

pull/695/head
YFdyh000 2020-04-19 04:11:30 +08:00
parent 20498ce453
commit aa3094f796
1 changed files with 27 additions and 23 deletions

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Threading.Tasks;
using v2rayN.Mode; using v2rayN.Mode;
namespace v2rayN.HttpProxyHandler namespace v2rayN.HttpProxyHandler
@ -148,33 +149,36 @@ namespace v2rayN.HttpProxyHandler
/// </summary> /// </summary>
/// <param name="config"></param> /// <param name="config"></param>
/// <param name="forced"></param> /// <param name="forced"></param>
public static void RestartHttpAgent(Config config, bool forced) public static Task RestartHttpAgent(Config config, bool forced)
{ {
bool isRestart = false; return Task.Run(() =>
if (config.listenerType == ListenerType.noHttpProxy) {
{ bool isRestart = false;
// 关闭http proxy时直接返回 if (config.listenerType == ListenerType.noHttpProxy)
return; {
} // 关闭http proxy时直接返回
//强制重启或者socks端口变化 return;
if (forced) }
{ //强制重启或者socks端口变化
isRestart = true; if (forced)
}
else
{
int localPort = config.GetLocalPort(Global.InboundSocks);
if (localPort != Global.socksPort)
{ {
isRestart = true; isRestart = true;
} }
} else
if (isRestart) {
{ int localPort = config.GetLocalPort(Global.InboundSocks);
CloseHttpAgent(config); if (localPort != Global.socksPort)
StartHttpAgent(config); {
} isRestart = true;
Update(config, false); }
}
if (isRestart)
{
CloseHttpAgent(config);
StartHttpAgent(config);
}
Update(config, false);
});
} }
public static string GetPacUrl() public static string GetPacUrl()