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