diff --git a/v2rayN/v2rayN/Forms/MainForm.Designer.cs b/v2rayN/v2rayN/Forms/MainForm.Designer.cs
index 4e516b81..0511b147 100644
--- a/v2rayN/v2rayN/Forms/MainForm.Designer.cs
+++ b/v2rayN/v2rayN/Forms/MainForm.Designer.cs
@@ -55,14 +55,14 @@
this.menuTcpingServer = new System.Windows.Forms.ToolStripMenuItem();
this.menuRealPingServer = new System.Windows.Forms.ToolStripMenuItem();
this.menuSpeedServer = new System.Windows.Forms.ToolStripMenuItem();
- this.tsbTestMe = new System.Windows.Forms.ToolStripMenuItem();
+ this.menuTestMe = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator();
this.menuExport2ClientConfig = new System.Windows.Forms.ToolStripMenuItem();
this.menuExport2ServerConfig = new System.Windows.Forms.ToolStripMenuItem();
this.menuExport2ShareUrl = new System.Windows.Forms.ToolStripMenuItem();
this.menuExport2SubContent = new System.Windows.Forms.ToolStripMenuItem();
- this.tsbServer = new System.Windows.Forms.ToolStripDropDownButton();
this.qrCodeControl = new v2rayN.Forms.QRCodeControl();
+ this.tsbServer = new System.Windows.Forms.ToolStripDropDownButton();
this.notifyMain = new System.Windows.Forms.NotifyIcon(this.components);
this.cmsMain = new System.Windows.Forms.ContextMenuStrip(this.components);
this.menuSysAgentMode = new System.Windows.Forms.ToolStripMenuItem();
@@ -94,6 +94,7 @@
this.toolSslPacPortLab = new System.Windows.Forms.ToolStripStatusLabel();
this.toolSslPacPort = new System.Windows.Forms.ToolStripStatusLabel();
this.toolSslBlank3 = new System.Windows.Forms.ToolStripStatusLabel();
+ this.toolSslServerLatency = new System.Windows.Forms.ToolStripStatusLabel();
this.toolSslServerSpeed = new System.Windows.Forms.ToolStripStatusLabel();
this.toolSslBlank4 = new System.Windows.Forms.ToolStripStatusLabel();
this.panel1 = new System.Windows.Forms.Panel();
@@ -196,7 +197,7 @@
this.menuTcpingServer,
this.menuRealPingServer,
this.menuSpeedServer,
- this.tsbTestMe,
+ this.menuTestMe,
this.toolStripSeparator6,
this.menuExport2ClientConfig,
this.menuExport2ServerConfig,
@@ -335,11 +336,11 @@
resources.ApplyResources(this.menuSpeedServer, "menuSpeedServer");
this.menuSpeedServer.Click += new System.EventHandler(this.menuSpeedServer_Click);
//
- // tsbTestMe
+ // menuTestMe
//
- this.tsbTestMe.Name = "tsbTestMe";
- resources.ApplyResources(this.tsbTestMe, "tsbTestMe");
- this.tsbTestMe.Click += new System.EventHandler(this.tsbTestMe_Click);
+ this.menuTestMe.Name = "menuTestMe";
+ resources.ApplyResources(this.menuTestMe, "menuTestMe");
+ this.menuTestMe.Click += new System.EventHandler(this.menuTestMe_Click);
//
// toolStripSeparator6
//
@@ -370,6 +371,11 @@
resources.ApplyResources(this.menuExport2SubContent, "menuExport2SubContent");
this.menuExport2SubContent.Click += new System.EventHandler(this.menuExport2SubContent_Click);
//
+ // qrCodeControl
+ //
+ resources.ApplyResources(this.qrCodeControl, "qrCodeControl");
+ this.qrCodeControl.Name = "qrCodeControl";
+ //
// tsbServer
//
this.tsbServer.DropDown = this.cmsLv;
@@ -377,11 +383,6 @@
resources.ApplyResources(this.tsbServer, "tsbServer");
this.tsbServer.Name = "tsbServer";
//
- // qrCodeControl
- //
- resources.ApplyResources(this.qrCodeControl, "qrCodeControl");
- this.qrCodeControl.Name = "qrCodeControl";
- //
// notifyMain
//
this.notifyMain.ContextMenuStrip = this.cmsMain;
@@ -543,6 +544,7 @@
this.toolSslPacPortLab,
this.toolSslPacPort,
this.toolSslBlank3,
+ this.toolSslServerLatency,
this.toolSslServerSpeed,
this.toolSslBlank4});
resources.ApplyResources(this.ssMain, "ssMain");
@@ -597,11 +599,19 @@
this.toolSslBlank3.Name = "toolSslBlank3";
this.toolSslBlank3.Spring = true;
//
+ // toolSslServerLatency
+ //
+ resources.ApplyResources(this.toolSslServerLatency, "toolSslServerLatency");
+ this.toolSslServerLatency.Name = "toolSslServerLatency";
+ this.toolSslServerLatency.Spring = true;
+ this.toolSslServerLatency.Click += new System.EventHandler(this.toolSslServerLatency_Click);
+ //
// toolSslServerSpeed
//
resources.ApplyResources(this.toolSslServerSpeed, "toolSslServerSpeed");
this.toolSslServerSpeed.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
this.toolSslServerSpeed.Name = "toolSslServerSpeed";
+ this.toolSslServerSpeed.Click += new System.EventHandler(this.toolSslServerSpeed_Click);
//
// toolSslBlank4
//
@@ -932,9 +942,10 @@
private System.Windows.Forms.ToolStripMenuItem tsbV2rayWebsite;
private System.Windows.Forms.ToolStripMenuItem menuKeepNothing;
private System.Windows.Forms.ToolStripMenuItem menuKeepPACNothing;
- private System.Windows.Forms.ToolStripMenuItem tsbTestMe;
+ private System.Windows.Forms.ToolStripMenuItem menuTestMe;
private System.Windows.Forms.ToolStripButton tsbReload;
private System.Windows.Forms.ToolStripButton tsbQRCodeSwitch;
+ private System.Windows.Forms.ToolStripStatusLabel toolSslServerLatency;
}
}
diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs
index b0d906ea..15ca5b08 100644
--- a/v2rayN/v2rayN/Forms/MainForm.cs
+++ b/v2rayN/v2rayN/Forms/MainForm.cs
@@ -11,6 +11,7 @@ using v2rayN.Tool;
using System.Diagnostics;
using System.Drawing;
using System.Net;
+using System.Threading.Tasks;
namespace v2rayN.Forms
{
@@ -379,8 +380,23 @@ namespace v2rayN.Forms
#endregion
- #region v2ray 操作
+ public static Task autoLatencyRefreshTask;
+ private void autoLatencyRefresh()
+ {
+ if (config.listenerType != ListenerType.noHttpProxy)
+ {
+ if (autoLatencyRefreshTask == null || autoLatencyRefreshTask.IsCompleted)
+ {
+ autoLatencyRefreshTask = Task.Run(async delegate
+ {
+ await Task.Delay(2000);
+ toolSslServerLatencyRefresh();
+ });
+ }
+ }
+ }
+ #region v2ray 操作
///
/// 载入V2ray
///
@@ -400,6 +416,8 @@ namespace v2rayN.Forms
ChangePACButtonStatus(config.listenerType);
tsbReload.Enabled = true;
+
+ autoLatencyRefresh();
}
///
@@ -674,15 +692,15 @@ namespace v2rayN.Forms
SpeedtestHandler statistics = new SpeedtestHandler(ref config, ref v2rayHandler, lvSelecteds, actionType, UpdateSpeedtestHandler);
}
- private void tsbTestMe_Click(object sender, EventArgs e)
+ private async void menuTestMe_Click(object sender, EventArgs e)
{
- string result = httpProxyTest() + "ms";
+ string result = await httpProxyTest() + "ms";
AppendText(false, string.Format(UIRes.I18N("TestMeOutput"), result));
}
- private int httpProxyTest()
+ private async Task httpProxyTest()
{
SpeedtestHandler statistics = new SpeedtestHandler(ref config, ref v2rayHandler, lvSelecteds, "", UpdateSpeedtestHandler);
- return statistics.RunAvailabilityCheck();
+ return await Task.Run(() => statistics.RunAvailabilityCheck());
}
private void menuExport2ClientConfig_Click(object sender, EventArgs e)
@@ -783,6 +801,7 @@ namespace v2rayN.Forms
//刷新
RefreshServers();
LoadV2ray();
+ toolSslServerLatencySet();
}
return 0;
}
@@ -1220,11 +1239,11 @@ namespace v2rayN.Forms
#region CheckUpdate
- private void askToDownload(DownloadHandle downloadHandle, string url)
+ private async void askToDownload(DownloadHandle downloadHandle, string url)
{
if (UI.ShowYesNo(string.Format(UIRes.I18N("DownloadYesNo"), url)) == DialogResult.Yes)
{
- if (httpProxyTest() > 0)
+ if (await httpProxyTest() > 0)
{
int httpPort = config.GetLocalPort(Global.InboundHttp);
WebProxy webProxy = new WebProxy(Global.Loopback, httpPort);
@@ -1566,5 +1585,25 @@ namespace v2rayN.Forms
#endregion
+
+ private async void toolSslServerLatencyRefresh()
+ {
+ toolSslServerLatencySet("Measuring...");
+ string result = await httpProxyTest() + "ms";
+ toolSslServerLatencySet(result);
+ }
+ private void toolSslServerLatencySet(string text = "")
+ {
+ toolSslServerLatency.Text = "Latency: " + text;
+ }
+ private void toolSslServerLatency_Click(object sender, EventArgs e)
+ {
+ toolSslServerLatencyRefresh();
+ }
+
+ private void toolSslServerSpeed_Click(object sender, EventArgs e)
+ {
+ //toolSslServerLatencyRefresh();
+ }
}
}
diff --git a/v2rayN/v2rayN/Forms/MainForm.resx b/v2rayN/v2rayN/Forms/MainForm.resx
index 28fe8826..62f3cdd2 100644
--- a/v2rayN/v2rayN/Forms/MainForm.resx
+++ b/v2rayN/v2rayN/Forms/MainForm.resx
@@ -716,6 +716,18 @@
System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ menuTestMe
+
+
+ 355, 22
+
+
+ Test current service status
+
+
+ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
menuUpdateSubscriptions
@@ -873,7 +885,7 @@
toolSslBlank1
- 195, 17
+ 152, 17
System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
@@ -885,7 +897,7 @@
toolSslBlank2
- 195, 17
+ 152, 17
System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
@@ -897,7 +909,7 @@
toolSslBlank3
- 195, 17
+ 152, 17
System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
@@ -959,6 +971,27 @@
System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ False
+
+
+ toolSslServerLatency
+
+
+ 144, 17
+
+
+ Latency:
+
+
+ MiddleLeft
+
+
+ The http proxy's latency time.
+
+
+ System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
False
@@ -972,7 +1005,7 @@
No
- 220, 17
+ 200, 17
SPEED Disabled
@@ -1418,18 +1451,6 @@
System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
- tsbTestMe
-
-
- 355, 22
-
-
- Test current service status
-
-
- System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
tsbV2rayWebsite
diff --git a/v2rayN/v2rayN/Handler/SpeedtestHandler.cs b/v2rayN/v2rayN/Handler/SpeedtestHandler.cs
index 303034b9..519b51e2 100644
--- a/v2rayN/v2rayN/Handler/SpeedtestHandler.cs
+++ b/v2rayN/v2rayN/Handler/SpeedtestHandler.cs
@@ -145,29 +145,24 @@ namespace v2rayN.Handler
}
}
- public int RunAvailabilityCheck() // alias: isLive
+ public async Task RunAvailabilityCheck() // alias: isLive
{
try
{
int httpPort = _config.GetLocalPort(Global.InboundHttp);
-
- Task t = Task.Run(() =>
+ try
{
- try
- {
- WebProxy webProxy = new WebProxy(Global.Loopback, httpPort);
- int responseTime = -1;
- string status = GetRealPingTime(Global.AvailabilityTestUrl, webProxy, out responseTime);
- bool noError = Utils.IsNullOrEmpty(status);
- return noError ? responseTime : -1;
- }
- catch (Exception ex)
- {
- Utils.SaveLog(ex.Message, ex);
- return -1;
- }
- });
- return t.Result;
+ WebProxy webProxy = new WebProxy(Global.Loopback, httpPort);
+ int responseTime = -1;
+ string status = GetRealPingTime(Global.AvailabilityTestUrl, webProxy, out responseTime);
+ bool noError = Utils.IsNullOrEmpty(status);
+ return noError ? responseTime : -1;
+ }
+ catch (Exception ex)
+ {
+ Utils.SaveLog(ex.Message, ex);
+ return -1;
+ }
}
catch (Exception ex)
{