Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
737d563ebb | ||
|
|
81b70195cf | ||
|
|
e60851153b | ||
|
|
009a15f0d9 | ||
|
|
f234775bd5 | ||
|
|
9b8bd0fa8a | ||
|
|
f74191946c |
@@ -149,7 +149,7 @@
|
|||||||
<value>203, 12</value>
|
<value>203, 12</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="label21.Text" xml:space="preserve">
|
<data name="label21.Text" xml:space="preserve">
|
||||||
<value>是否允许不安全连接(allowInsecure)</value>
|
<value>允许不安全连接(allowInsecure)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="cmbAllowInsecure.Location" type="System.Drawing.Point, System.Drawing">
|
<data name="cmbAllowInsecure.Location" type="System.Drawing.Point, System.Drawing">
|
||||||
<value>223, 7</value>
|
<value>223, 7</value>
|
||||||
|
|||||||
@@ -444,7 +444,7 @@ namespace v2rayN.Forms
|
|||||||
|
|
||||||
private void linkLabelRoutingDoc_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
private void linkLabelRoutingDoc_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Process.Start("https://www.v2ray.com/chapter_02/03_routing.html#routingobject");
|
System.Diagnostics.Process.Start("https://www.v2fly.org/chapter_02/03_routing.html");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@
|
|||||||
<value>222, 16</value>
|
<value>222, 16</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="chkdefAllowInsecure.Text" xml:space="preserve">
|
<data name="chkdefAllowInsecure.Text" xml:space="preserve">
|
||||||
<value>是否允许不安全连接(allowInsecure)</value>
|
<value>底层传输安全选tls时,默认允许不安全连接(allowInsecure)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="label16.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="label16.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>53, 12</value>
|
<value>53, 12</value>
|
||||||
|
|||||||
@@ -136,13 +136,15 @@ namespace v2rayN.Handler
|
|||||||
string curVersion;
|
string curVersion;
|
||||||
string message;
|
string message;
|
||||||
string url;
|
string url;
|
||||||
if (type == "Core") {
|
if (type == "Core")
|
||||||
|
{
|
||||||
curVersion = "v" + getV2rayVersion();
|
curVersion = "v" + getV2rayVersion();
|
||||||
message = string.Format(UIRes.I18N("IsLatestCore"), curVersion);
|
message = string.Format(UIRes.I18N("IsLatestCore"), curVersion);
|
||||||
string osBit = Environment.Is64BitProcess ? "64" : "32";
|
string osBit = Environment.Is64BitProcess ? "64" : "32";
|
||||||
url = string.Format(coreUrl, version, osBit);
|
url = string.Format(coreUrl, version, osBit);
|
||||||
}
|
}
|
||||||
else if (type == "v2rayN") {
|
else if (type == "v2rayN")
|
||||||
|
{
|
||||||
curVersion = FileVersionInfo.GetVersionInfo(Utils.GetExePath()).FileVersion.ToString();
|
curVersion = FileVersionInfo.GetVersionInfo(Utils.GetExePath()).FileVersion.ToString();
|
||||||
message = string.Format(UIRes.I18N("IsLatestN"), curVersion);
|
message = string.Format(UIRes.I18N("IsLatestN"), curVersion);
|
||||||
url = string.Format(nUrl, version);
|
url = string.Format(nUrl, version);
|
||||||
@@ -172,8 +174,9 @@ namespace v2rayN.Handler
|
|||||||
|
|
||||||
#region Download
|
#region Download
|
||||||
|
|
||||||
public void DownloadFileAsync(string url, WebProxy webProxy, int downloadTimeout)
|
public WebClientEx DownloadFileAsync(string url, WebProxy webProxy, int downloadTimeout)
|
||||||
{
|
{
|
||||||
|
WebClientEx ws = new WebClientEx();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Utils.SetSecurityProtocol();
|
Utils.SetSecurityProtocol();
|
||||||
@@ -182,7 +185,7 @@ namespace v2rayN.Handler
|
|||||||
progressPercentage = -1;
|
progressPercentage = -1;
|
||||||
totalBytesToReceive = 0;
|
totalBytesToReceive = 0;
|
||||||
|
|
||||||
WebClientEx ws = new WebClientEx();
|
//WebClientEx ws = new WebClientEx();
|
||||||
DownloadTimeout = downloadTimeout;
|
DownloadTimeout = downloadTimeout;
|
||||||
if (webProxy != null)
|
if (webProxy != null)
|
||||||
{
|
{
|
||||||
@@ -199,6 +202,7 @@ namespace v2rayN.Handler
|
|||||||
|
|
||||||
Error?.Invoke(this, new ErrorEventArgs(ex));
|
Error?.Invoke(this, new ErrorEventArgs(ex));
|
||||||
}
|
}
|
||||||
|
return ws;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ws_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
|
void ws_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
|
||||||
|
|||||||
@@ -11,26 +11,17 @@ namespace v2rayN.Handler
|
|||||||
{
|
{
|
||||||
class SpeedtestHandler
|
class SpeedtestHandler
|
||||||
{
|
{
|
||||||
private DownloadHandle downloadHandle2;
|
|
||||||
private Config _config;
|
private Config _config;
|
||||||
private V2rayHandler _v2rayHandler;
|
private V2rayHandler _v2rayHandler;
|
||||||
private List<int> _selecteds;
|
private List<int> _selecteds;
|
||||||
Action<int, string> _updateFunc;
|
Action<int, string> _updateFunc;
|
||||||
|
|
||||||
private int testCounter = 0;
|
|
||||||
private int ItemIndex
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _selecteds[testCounter - 1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public SpeedtestHandler(ref Config config, ref V2rayHandler v2rayHandler, List<int> selecteds, string actionType, Action<int, string> update)
|
public SpeedtestHandler(ref Config config, ref V2rayHandler v2rayHandler, List<int> selecteds, string actionType, Action<int, string> update)
|
||||||
{
|
{
|
||||||
_config = config;
|
_config = config;
|
||||||
_v2rayHandler = v2rayHandler;
|
_v2rayHandler = v2rayHandler;
|
||||||
_selecteds = selecteds;
|
_selecteds = Utils.DeepCopy(selecteds);
|
||||||
_updateFunc = update;
|
_updateFunc = update;
|
||||||
|
|
||||||
if (actionType == "ping")
|
if (actionType == "ping")
|
||||||
@@ -178,6 +169,7 @@ namespace v2rayN.Handler
|
|||||||
|
|
||||||
private void RunSpeedTest()
|
private void RunSpeedTest()
|
||||||
{
|
{
|
||||||
|
int testCounter = 0;
|
||||||
int pid = -1;
|
int pid = -1;
|
||||||
|
|
||||||
if (_config.vmess.Count <= 0)
|
if (_config.vmess.Count <= 0)
|
||||||
@@ -188,39 +180,41 @@ namespace v2rayN.Handler
|
|||||||
pid = _v2rayHandler.LoadV2rayConfigString(_config, _selecteds);
|
pid = _v2rayHandler.LoadV2rayConfigString(_config, _selecteds);
|
||||||
|
|
||||||
string url = _config.speedTestUrl;
|
string url = _config.speedTestUrl;
|
||||||
testCounter = 0;
|
DownloadHandle downloadHandle2 = new DownloadHandle();
|
||||||
if (downloadHandle2 == null)
|
downloadHandle2.UpdateCompleted += (sender2, args) =>
|
||||||
{
|
{
|
||||||
downloadHandle2 = new DownloadHandle();
|
_updateFunc(testCounter, args.Msg);
|
||||||
downloadHandle2.UpdateCompleted += (sender2, args) =>
|
};
|
||||||
{
|
downloadHandle2.Error += (sender2, args) =>
|
||||||
_updateFunc(ItemIndex, args.Msg);
|
|
||||||
if (args.Success) StartNext();
|
|
||||||
};
|
|
||||||
downloadHandle2.Error += (sender2, args) =>
|
|
||||||
{
|
|
||||||
_updateFunc(ItemIndex, args.GetException().Message);
|
|
||||||
StartNext();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
StartNext();
|
|
||||||
|
|
||||||
void StartNext()
|
|
||||||
{
|
{
|
||||||
if (testCounter >= _selecteds.Count)
|
_updateFunc(testCounter, args.GetException().Message);
|
||||||
|
};
|
||||||
|
|
||||||
|
var timeout = 12;
|
||||||
|
foreach (int itemIndex in _selecteds)
|
||||||
|
{
|
||||||
|
if (itemIndex >= _config.vmess.Count)
|
||||||
{
|
{
|
||||||
if (pid > 0) _v2rayHandler.V2rayStopPid(pid);
|
break;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_config.vmess[itemIndex].configType == (int)EConfigType.Custom)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
testCounter = itemIndex;
|
||||||
int httpPort = _config.GetLocalPort("speedtest");
|
int httpPort = _config.GetLocalPort("speedtest");
|
||||||
int index = _selecteds[testCounter];
|
|
||||||
|
|
||||||
testCounter++;
|
WebProxy webProxy = new WebProxy(Global.Loopback, httpPort + itemIndex);
|
||||||
WebProxy webProxy = new WebProxy(Global.Loopback, httpPort + index);
|
var ws = downloadHandle2.DownloadFileAsync(url, webProxy, timeout - 2);
|
||||||
downloadHandle2.DownloadFileAsync(url, webProxy, 10);
|
|
||||||
|
Thread.Sleep(1000 * timeout);
|
||||||
|
|
||||||
|
ws.CancelAsync();
|
||||||
|
|
||||||
|
Thread.Sleep(1000 * 2);
|
||||||
}
|
}
|
||||||
|
if (pid > 0) _v2rayHandler.V2rayStopPid(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user