When testing speed, skip items with incorrect latency

master
2dust 2025-02-21 14:33:43 +08:00
parent 390061f9bd
commit 40c1498226
1 changed files with 11 additions and 3 deletions

View File

@ -261,11 +261,18 @@ namespace ServiceLib.Services
if (pid > 0) if (pid > 0)
{ {
await Task.Delay(500); await Task.Delay(500);
await DoRealPing(downloadHandle, it); var delay = await DoRealPing(downloadHandle, it);
if (blSpeedTest) if (blSpeedTest)
{
if (delay > 0)
{ {
await DoSpeedTest(downloadHandle, it); await DoSpeedTest(downloadHandle, it);
} }
else
{
UpdateFunc(it.IndexId, "", ResUI.SpeedtestingSkip);
}
}
} }
else else
{ {
@ -289,13 +296,14 @@ namespace ServiceLib.Services
Task.WaitAll(tasks.ToArray()); Task.WaitAll(tasks.ToArray());
} }
private async Task DoRealPing(DownloadService downloadHandle, ServerTestItem it) private async Task<int> DoRealPing(DownloadService downloadHandle, ServerTestItem it)
{ {
var webProxy = new WebProxy($"socks5://{Global.Loopback}:{it.Port}"); var webProxy = new WebProxy($"socks5://{Global.Loopback}:{it.Port}");
var responseTime = await downloadHandle.GetRealPingTime(_config.SpeedTestItem.SpeedPingTestUrl, webProxy, 10); var responseTime = await downloadHandle.GetRealPingTime(_config.SpeedTestItem.SpeedPingTestUrl, webProxy, 10);
ProfileExHandler.Instance.SetTestDelay(it.IndexId, responseTime); ProfileExHandler.Instance.SetTestDelay(it.IndexId, responseTime);
UpdateFunc(it.IndexId, responseTime.ToString()); UpdateFunc(it.IndexId, responseTime.ToString());
return responseTime;
} }
private async Task DoSpeedTest(DownloadService downloadHandle, ServerTestItem it) private async Task DoSpeedTest(DownloadService downloadHandle, ServerTestItem it)