From ef01b4aa5edf5586a7508a86d2f4539b0e061a1d Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Wed, 23 Oct 2019 15:18:21 +0800 Subject: [PATCH] fix pac --- v2rayN/v2rayN/Base/HttpWebServerB.cs | 6 ++++ v2rayN/v2rayN/Forms/MainForm.cs | 31 +++++++------------ v2rayN/v2rayN/Handler/SpeedtestHandler.cs | 3 ++ v2rayN/v2rayN/Handler/StatisticsHandler.cs | 1 + .../HttpProxyHandler/HttpProxyHandle.cs | 13 ++++---- .../HttpProxyHandler/PACServerHandle.cs | 31 ++++++++++++------- v2rayN/v2rayN/Properties/AssemblyInfo.cs | 2 +- 7 files changed, 48 insertions(+), 39 deletions(-) diff --git a/v2rayN/v2rayN/Base/HttpWebServerB.cs b/v2rayN/v2rayN/Base/HttpWebServerB.cs index 70ac2759993..73e596d11dc 100644 --- a/v2rayN/v2rayN/Base/HttpWebServerB.cs +++ b/v2rayN/v2rayN/Base/HttpWebServerB.cs @@ -39,8 +39,14 @@ private void StartListen() while (true) { + if (!listener.Pending()) + { + continue; + } + TcpClient socket = listener.AcceptTcpClient(); Thread thread = new Thread(new ParameterizedThreadStart(ProcessThread)); + thread.IsBackground = true; thread.Start(socket); Thread.Sleep(1); } diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs index 5f31540f88c..76e27d3c9b8 100644 --- a/v2rayN/v2rayN/Forms/MainForm.cs +++ b/v2rayN/v2rayN/Forms/MainForm.cs @@ -33,6 +33,13 @@ public MainForm() Application.ApplicationExit += (sender, args) => { Utils.ClearTempPath(); + + v2rayHandler.V2rayStop(); + HttpProxyHandle.CloseHttpAgent(config); + PACServerHandle.Stop(); + + ConfigHandler.SaveConfig(ref config); + statistics?.SaveToFile(); statistics?.Close(); }; } @@ -79,18 +86,9 @@ private void MainForm_FormClosing(object sender, FormClosingEventArgs e) if (e.CloseReason == CloseReason.UserClosing) { e.Cancel = true; - - statistics?.SaveToFile(); - HideForm(); return; - } - if (e.CloseReason == CloseReason.ApplicationExitCall) - { - ConfigHandler.SaveConfig(ref config); - statistics?.SaveToFile(); - statistics?.Close(); - } + } } private void MainForm_Resize(object sender, EventArgs e) @@ -117,7 +115,7 @@ protected override void WndProc(ref Message m) { case WM_QUERYENDSESSION: Utils.SaveLog("Windows shutdown UnsetProxy"); - //CloseV2ray(); + ConfigHandler.ToJsonFile(config); statistics?.SaveToFile(); ProxySetting.UnsetProxy(); @@ -1006,16 +1004,11 @@ private void notifyMain_MouseClick(object sender, MouseEventArgs e) } private void menuExit_Click(object sender, EventArgs e) - { - CloseV2ray(); + { this.Visible = false; - this.Close(); - - statistics?.Close(); - - //this.Dispose(); - //System.Environment.Exit(System.Environment.ExitCode); + this.Close(); + Application.Exit(); } diff --git a/v2rayN/v2rayN/Handler/SpeedtestHandler.cs b/v2rayN/v2rayN/Handler/SpeedtestHandler.cs index fefabfe4032..f5d82f50f25 100644 --- a/v2rayN/v2rayN/Handler/SpeedtestHandler.cs +++ b/v2rayN/v2rayN/Handler/SpeedtestHandler.cs @@ -37,16 +37,19 @@ public SpeedtestHandler(ref Config config, ref V2rayHandler v2rayHandler, List