Publish Zonghengjia Windows 0.3.17 client source

This commit is contained in:
2026-11-15 21:33:18 +08:00
parent 36de255318
commit ebec81ceb1
25 changed files with 3745 additions and 3412 deletions
+32
View File
@@ -0,0 +1,32 @@
namespace UCVL.VPNPlus;
// Give an authorized port a full TCP probe budget. Quick failures may retry
// within the same round. The readiness policy schedules a confirmation round.
internal static class TailnetEndpointConfirmation
{
private const int Attempts = 3;
internal static async Task<bool> ProbeAsync(Func<CancellationToken, Task<bool>> probe,
CancellationToken token, TimeSpan? budget = null)
{
token.ThrowIfCancellationRequested();
using var deadline = CancellationTokenSource.CreateLinkedTokenSource(token);
deadline.CancelAfter(budget ?? TimeSpan.FromSeconds(TailnetTransport.EndpointProbeTimeoutSeconds));
for (var attempt = 0; attempt < Attempts; attempt++)
{
token.ThrowIfCancellationRequested();
if (deadline.IsCancellationRequested) return false;
try
{
var reachable = await probe(deadline.Token).WaitAsync(deadline.Token).ConfigureAwait(false);
token.ThrowIfCancellationRequested();
if (deadline.IsCancellationRequested) return false;
if (reachable) return true;
}
catch (OperationCanceledException) when (!token.IsCancellationRequested && deadline.IsCancellationRequested) { return false; }
catch (OperationCanceledException) { throw; }
catch (Exception) { /* One failed TCP attempt is inconclusive. */ }
}
token.ThrowIfCancellationRequested();
return false;
}
}