更新时使用代理(如可用)

pull/567/head
YFdyh000 5 years ago
parent d2ab186e44
commit 3daa8f479c

@ -9,7 +9,8 @@ using v2rayN.Mode;
using v2rayN.Base; using v2rayN.Base;
using v2rayN.Tool; using v2rayN.Tool;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Net;
namespace v2rayN.Forms namespace v2rayN.Forms
{ {
@ -1185,6 +1186,22 @@ namespace v2rayN.Forms
#region CheckUpdate #region CheckUpdate
private void askToDownload(DownloadHandle downloadHandle, string url)
{
if (UI.ShowYesNo(string.Format(UIRes.I18N("DownloadYesNo"), url)) == DialogResult.Yes)
{
if (httpProxyTest() > 0)
{
int httpPort = config.GetLocalPort(Global.InboundHttp);
WebProxy webProxy = new WebProxy(Global.Loopback, httpPort);
downloadHandle.DownloadFileAsync(url, webProxy, 60);
}
else
{
downloadHandle.DownloadFileAsync(url, null, 60);
}
}
}
private void tsbCheckUpdateN_Click(object sender, EventArgs e) private void tsbCheckUpdateN_Click(object sender, EventArgs e)
{ {
//System.Diagnostics.Process.Start(Global.UpdateUrl); //System.Diagnostics.Process.Start(Global.UpdateUrl);
@ -1201,15 +1218,7 @@ namespace v2rayN.Forms
string url = args.Msg; string url = args.Msg;
this.Invoke((MethodInvoker)(delegate this.Invoke((MethodInvoker)(delegate
{ {
askToDownload(downloadHandle, url);
if (UI.ShowYesNo(string.Format(UIRes.I18N("DownloadYesNo"), url)) == DialogResult.No)
{
return;
}
else
{
downloadHandle.DownloadFileAsync(url, null, -1);
}
})); }));
} }
else else
@ -1267,15 +1276,7 @@ namespace v2rayN.Forms
string url = args.Msg; string url = args.Msg;
this.Invoke((MethodInvoker)(delegate this.Invoke((MethodInvoker)(delegate
{ {
askToDownload(downloadHandle, url);
if (UI.ShowYesNo(string.Format(UIRes.I18N("DownloadYesNo"), url)) == DialogResult.No)
{
return;
}
else
{
downloadHandle.DownloadFileAsync(url, null, -1);
}
})); }));
} }
else else
@ -1519,9 +1520,13 @@ namespace v2rayN.Forms
private void tsbTestMe_Click(object sender, EventArgs e) private void tsbTestMe_Click(object sender, EventArgs e)
{ {
SpeedtestHandler statistics = new SpeedtestHandler(ref config, ref v2rayHandler, lvSelecteds, "", UpdateSpeedtestHandler); string result = httpProxyTest() + "ms";
string result = statistics.RunAvailabilityCheck() + "ms";
AppendText(false, string.Format(UIRes.I18N("TestMeOutput"), result)); AppendText(false, string.Format(UIRes.I18N("TestMeOutput"), result));
} }
private int httpProxyTest()
{
SpeedtestHandler statistics = new SpeedtestHandler(ref config, ref v2rayHandler, lvSelecteds, "", UpdateSpeedtestHandler);
return statistics.RunAvailabilityCheck();
}
} }
} }

@ -156,7 +156,7 @@ namespace v2rayN.Handler
{ {
int httpPort = _config.GetLocalPort(Global.InboundHttp); int httpPort = _config.GetLocalPort(Global.InboundHttp);
Task<int> t = Task.Factory.StartNew(() => Task<int> t = Task.Run(() =>
{ {
try try
{ {

Loading…
Cancel
Save