Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions v2rayN/ServiceLib.UdpTest/UdpTestService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,13 @@ public async Task<TimeSpan> SendUdpRequestAsync(string targetServerHost, int soc
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
}
}

Expand Down
16 changes: 14 additions & 2 deletions v2rayN/ServiceLib/Services/SpeedtestService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,20 @@ await downloadHandle.DownloadDataAsync(url, webProxy, async (success, msg) =>
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());
Expand Down
Loading