Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c29ccf76d5 | ||
|
|
5907bf388c | ||
|
|
54adaffb92 |
@@ -578,13 +578,11 @@ namespace v2rayN.Forms
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (int k = lvSelecteds.Count - 1; k >= 0; k--)
|
||||
{
|
||||
ConfigHandler.RemoveServer(ref config, lvSelecteds[k]);
|
||||
}
|
||||
|
||||
ConfigHandler.RemoveServer(ref config, lvSelecteds);
|
||||
|
||||
RefreshServers();
|
||||
LoadV2ray();
|
||||
|
||||
}
|
||||
|
||||
private void menuRemoveDuplicateServer_Click(object sender, EventArgs e)
|
||||
|
||||
@@ -236,19 +236,27 @@ namespace v2rayN.Handler
|
||||
/// <param name="config"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public static int RemoveServer(ref Config config, int index)
|
||||
public static int RemoveServer(ref Config config, List<int> indexs)
|
||||
{
|
||||
if (index < 0 || index > config.vmess.Count - 1)
|
||||
var itemId = config.getItemId();
|
||||
|
||||
for (int k = indexs.Count - 1; k >= 0; k--)
|
||||
{
|
||||
return -1;
|
||||
var index = indexs[k];
|
||||
if (index < 0 || index > config.vmess.Count - 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
config.vmess.RemoveAt(index);
|
||||
}
|
||||
|
||||
//删除
|
||||
config.vmess.RemoveAt(index);
|
||||
|
||||
|
||||
//移除的是活动的
|
||||
if (config.index.Equals(index))
|
||||
var index_ = config.vmess.FindIndex(it => it.getItemId() == itemId);
|
||||
if (index_ >= 0)
|
||||
{
|
||||
config.index = index_;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (config.vmess.Count > 0)
|
||||
{
|
||||
@@ -258,13 +266,8 @@ namespace v2rayN.Handler
|
||||
{
|
||||
config.index = -1;
|
||||
}
|
||||
Global.reloadV2ray = true;
|
||||
}
|
||||
else if (index < config.index)//移除活动之前的
|
||||
{
|
||||
config.index--;
|
||||
Global.reloadV2ray = true;
|
||||
}
|
||||
Global.reloadV2ray = true;
|
||||
|
||||
ToJsonFile(config);
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
return ws;
|
||||
}
|
||||
|
||||
|
||||
void ws_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
|
||||
{
|
||||
if (UpdateCompleted != null)
|
||||
@@ -108,7 +108,7 @@ namespace v2rayN.Handler
|
||||
if (e.Error == null
|
||||
|| Utils.IsNullOrEmpty(e.Error.ToString()))
|
||||
{
|
||||
|
||||
((WebClientEx)sender).Dispose();
|
||||
TimeSpan ts = (DateTime.Now - totalDatetime);
|
||||
string speed = string.Format("{0} M/s", (totalBytesToReceive / ts.TotalMilliseconds / 1000).ToString("#0.0"));
|
||||
UpdateCompleted(this, new ResultEventArgs(true, speed.PadLeft(8, ' ')));
|
||||
@@ -189,5 +189,34 @@ namespace v2rayN.Handler
|
||||
}
|
||||
}
|
||||
|
||||
public WebClientEx DownloadDataAsync(string url, WebProxy webProxy, int downloadTimeout)
|
||||
{
|
||||
WebClientEx ws = new WebClientEx();
|
||||
try
|
||||
{
|
||||
Utils.SetSecurityProtocol();
|
||||
UpdateCompleted?.Invoke(this, new ResultEventArgs(false, UIRes.I18N("Downloading")));
|
||||
|
||||
progressPercentage = -1;
|
||||
totalBytesToReceive = 0;
|
||||
|
||||
DownloadTimeout = downloadTimeout;
|
||||
if (webProxy != null)
|
||||
{
|
||||
ws.Proxy = webProxy;
|
||||
}
|
||||
|
||||
ws.DownloadProgressChanged += ws_DownloadProgressChanged;
|
||||
ws.DownloadDataCompleted += ws_DownloadFileCompleted;
|
||||
ws.DownloadDataAsync(new Uri(url));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utils.SaveLog(ex.Message, ex);
|
||||
|
||||
Error?.Invoke(this, new ErrorEventArgs(ex));
|
||||
}
|
||||
return ws;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,11 +220,12 @@ namespace v2rayN.Handler
|
||||
int httpPort = _config.GetLocalPort("speedtest");
|
||||
|
||||
WebProxy webProxy = new WebProxy(Global.Loopback, httpPort + itemIndex);
|
||||
var ws = downloadHandle2.DownloadFileAsync(url, webProxy, timeout - 2);
|
||||
var ws = downloadHandle2.DownloadDataAsync(url, webProxy, timeout - 2);
|
||||
|
||||
Thread.Sleep(1000 * timeout);
|
||||
|
||||
ws.CancelAsync();
|
||||
ws.Dispose();
|
||||
|
||||
Thread.Sleep(1000 * 2);
|
||||
}
|
||||
|
||||
@@ -32,4 +32,4 @@ using System.Runtime.InteropServices;
|
||||
// 方法是按如下所示使用“*”:
|
||||
//[assembly: AssemblyVersion("1.0.*")]
|
||||
//[assembly: AssemblyVersion("1.0.0")]
|
||||
[assembly: AssemblyFileVersion("4.23")]
|
||||
[assembly: AssemblyFileVersion("4.24")]
|
||||
|
||||
Reference in New Issue
Block a user