Windows 0.3.4 connection resilience and fixed-grid source delta; no private history or other platform changes
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
namespace UCVL.VPNPlus;
|
||||
|
||||
// A bounded round tolerates isolated ICMP loss. This is address reachability,
|
||||
// never a substitute for an authenticated proxy grant or a business-site test.
|
||||
internal static class TailnetPingConfirmation
|
||||
{
|
||||
internal const int Attempts = 3;
|
||||
internal static async Task<bool> ProbeAsync(Func<CancellationToken, Task<bool>> ping,
|
||||
CancellationToken token, TimeSpan? budget = null)
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
using var deadline = CancellationTokenSource.CreateLinkedTokenSource(token);
|
||||
deadline.CancelAfter(budget ?? TimeSpan.FromSeconds(4));
|
||||
for (var attempt = 0; attempt < Attempts; attempt++)
|
||||
{
|
||||
try
|
||||
{
|
||||
var reachable = await ping(deadline.Token).WaitAsync(deadline.Token).ConfigureAwait(false);
|
||||
token.ThrowIfCancellationRequested();
|
||||
if (reachable) return true;
|
||||
}
|
||||
catch (OperationCanceledException) when (!token.IsCancellationRequested && deadline.IsCancellationRequested) { return false; }
|
||||
catch (OperationCanceledException) { throw; }
|
||||
catch (Exception) { /* One failed ICMP attempt is inconclusive. */ }
|
||||
token.ThrowIfCancellationRequested();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user