Publish Zonghengjia Windows 0.3.13 client source

This commit is contained in:
2026-11-13 10:35:04 +08:00
parent 1590443809
commit 839434a313
55 changed files with 2324 additions and 963 deletions
+3 -31
View File
@@ -394,8 +394,9 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt
await TunRouting.WaitForAdapterAsync(cancellationToken, requireIpv4Ready: true);
beginStartupLearning?.Invoke(_learningEpoch.Token);
await ProxyDnsPolicy.EnableAsync(_baseConfigJson, cancellationToken);
StatusMessage?.Invoke("正在等待 Windows 网络与 DNS 就绪…");
await WaitForDnsReadyAsync(cancellationToken);
// The DNS policy is applied above. Management readiness does not
// require resolving the HTTPS authority through any DNS provider.
StatusMessage?.Invoke("Windows 网卡和 DNS 配置已应用。");
await Task.Delay(250, cancellationToken);
_boundNetwork = physicalNetwork;
SafeDeleteConfig();
@@ -407,35 +408,6 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt
}
}
private static async Task WaitForDnsReadyAsync(CancellationToken cancellationToken)
{
var started = Stopwatch.StartNew();
Exception? lastError = null;
for (var attempt = 0; attempt < 40; attempt++)
{
try
{
var addresses = await Dns.GetHostAddressesAsync("vpn.example.invalid", cancellationToken);
if (addresses.Any(address => address.AddressFamily == AddressFamily.InterNetwork))
{
AppPaths.WriteLog($"Windows DNS 已就绪({started.ElapsedMilliseconds} ms)。");
return;
}
}
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
{
throw;
}
catch (Exception exception) when (exception is SocketException or IOException)
{
lastError = exception;
}
await Task.Delay(500, cancellationToken);
}
throw new InvalidOperationException(
$"Windows DNS 在 20 秒内未就绪,已恢复原网络。{lastError?.GetBaseException().Message}");
}
private async Task StopCoreAsync()
{
// A rejected second instance must not delete the active owner's DNS,