pull/188/head 2.47
2dust 2019-10-23 15:18:21 +08:00
parent c0340843eb
commit ef01b4aa5e
7 changed files with 48 additions and 39 deletions

View File

@ -39,8 +39,14 @@ namespace v2rayN.Base
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);
}

View File

@ -33,6 +33,13 @@ namespace v2rayN.Forms
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 @@ namespace v2rayN.Forms
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 @@ namespace v2rayN.Forms
{
case WM_QUERYENDSESSION:
Utils.SaveLog("Windows shutdown UnsetProxy");
//CloseV2ray();
ConfigHandler.ToJsonFile(config);
statistics?.SaveToFile();
ProxySetting.UnsetProxy();
@ -1006,16 +1004,11 @@ namespace v2rayN.Forms
}
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();
}

View File

@ -37,16 +37,19 @@ namespace v2rayN.Handler
if (actionType == "ping")
{
_workThread = new Thread(new ThreadStart(RunPing));
_workThread.IsBackground = true;
_workThread.Start();
}
if (actionType == "tcping")
{
_workThread = new Thread(new ThreadStart(RunTcping));
_workThread.IsBackground = true;
_workThread.Start();
}
else if (actionType == "realping")
{
_workThread = new Thread(new ThreadStart(RunRealPing));
_workThread.IsBackground = true;
_workThread.Start();
}
else if (actionType == "speedtest")

View File

@ -105,6 +105,7 @@ namespace v2rayN.Handler
GrpcInit();
workThread_ = new Thread(new ThreadStart(Run));
workThread_.IsBackground = true;
workThread_.Start();
}

View File

@ -30,33 +30,33 @@ namespace v2rayN.HttpProxyHandler
}
if (type == 1)
{
PACServerHandle.Stop();
//PACServerHandle.Stop();
SysProxyHandle.SetIEProxy(true, true, $"{Global.Loopback}:{port}", null);
}
else if (type == 2)
{
string pacUrl = GetPacUrl();
SysProxyHandle.SetIEProxy(true, false, null, pacUrl);
PACServerHandle.Stop();
//PACServerHandle.Stop();
PACServerHandle.Init(config);
}
else if (type == 3)
{
PACServerHandle.Stop();
//PACServerHandle.Stop();
SysProxyHandle.SetIEProxy(false, false, null, null);
}
else if (type == 4)
{
string pacUrl = GetPacUrl();
SysProxyHandle.SetIEProxy(false, false, null, null);
PACServerHandle.Stop();
//PACServerHandle.Stop();
PACServerHandle.Init(config);
}
}
else
{
SysProxyHandle.SetIEProxy(false, false, null, null);
PACServerHandle.Stop();
//PACServerHandle.Stop();
}
}
catch (Exception ex)
@ -104,8 +104,7 @@ namespace v2rayN.HttpProxyHandler
Global.sysAgent = false;
Global.socksPort = 0;
Global.httpPort = 0;
Global.pacPort = 0;
Global.httpPort = 0;
}
catch
{

View File

@ -28,6 +28,8 @@ namespace v2rayN.HttpProxyHandler
public static void Init(Config config)
{
Global.pacPort = config.GetLocalPort("pac");
if (InitServer("*"))
{
pacPort = Global.pacPort;
@ -122,18 +124,23 @@ namespace v2rayN.HttpProxyHandler
public static void Stop()
{
//try
//{
// if (server != null)
// {
// server.Stop();
// server = null;
// }
//}
//catch (Exception ex)
//{
// Utils.SaveLog("Webserver Stop " + ex.Message);
//}
try
{
if (server != null)
{
server.Stop();
server = null;
}
if (serverB != null)
{
serverB.Stop();
serverB = null;
}
}
catch (Exception ex)
{
Utils.SaveLog("Webserver Stop " + ex.Message);
}
//try
//{

View File

@ -33,4 +33,4 @@ using System.Runtime.InteropServices;
// 方法是按如下所示使用“*”:
//[assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("2.46")]
[assembly: AssemblyFileVersion("2.47")]