mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-01 18:15:00 +03:00
Fix udp test (#10484)
This commit is contained in:
@@ -135,16 +135,13 @@ public class UdpTestService
|
||||
roundTripTime = currentRoundTripTime;
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException) when (timeoutCts.IsCancellationRequested)
|
||||
catch (OperationCanceledException) when (ct.IsCancellationRequested)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
if (attempt == 1 && roundTripTime == TimeSpan.MaxValue)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
// Timeout, continue to next attempt
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -541,8 +541,20 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||
private async Task<int> DoUdpTest(ServerTestItem it,
|
||||
ConcurrentDictionary<string, byte> completedIds, CancellationToken ct = default)
|
||||
{
|
||||
var udpService = UdpTestService.CreateFromTarget(_config?.SpeedTestItem.UdpTestTarget, out var udpTestUrl);
|
||||
var responseTime = (int)(await udpService.SendUdpRequestAsync(udpTestUrl, it.Port, ct)).TotalMilliseconds;
|
||||
var responseTime = -1;
|
||||
try
|
||||
{
|
||||
var udpService = UdpTestService.CreateFromTarget(_config?.SpeedTestItem.UdpTestTarget, out var udpTestUrl);
|
||||
responseTime = (int)(await udpService.SendUdpRequestAsync(udpTestUrl, it.Port, ct)).TotalMilliseconds;
|
||||
}
|
||||
catch (OperationCanceledException) when (ct.IsCancellationRequested)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
|
||||
ProfileExManager.Instance.SetTestDelay(it.IndexId, responseTime);
|
||||
await UpdateFunc(it.IndexId, responseTime.ToString());
|
||||
|
||||
Reference in New Issue
Block a user