Windows 0.3.2 clean startup and compact UI source delta; no private history or other platform changes

This commit is contained in:
2026-11-02 04:13:58 +00:00
parent 1cf54a46e4
commit bfe8d6c62a
23 changed files with 4001 additions and 3092 deletions
+28 -31
View File
@@ -196,37 +196,32 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt
if (preferred is not null && !TailnetTransport.SameAuthorizedFallback(preferred, original))
throw new InvalidOperationException("Tailscale 恢复入口与已授权线路不匹配。");
await InitializeAsync(cancellationToken);
await _lifecycle.WaitAsync(cancellationToken);
try
{
await StopCoreAsync();
_baseConfigJson = configJson;
_tailnetFallbackConfigJson = preferred is not null ? original : tailnetFallbackConfigJson;
_preferredTailnetConfigJson = preferred;
_routeMode = routeMode;
_nodeSlug = nodeSlug;
await StartCoreAsync(cancellationToken);
}
catch
{
await StopCoreAsync().ConfigureAwait(false);
throw;
}
finally
{
_lifecycle.Release();
}
if (_routeMode == "smart")
{
// The same three fixed health destinations, but first validate their real
// physical direct path. Never mark all server candidate domains as proxy.
StatusMessage?.Invoke("正在验证本地直连与代理路径…");
using var warmup = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, _learningEpoch.Token);
warmup.CancelAfter(TimeSpan.FromSeconds(15));
await Task.WhenAll(new[] { "chatgpt.com", "api.openai.com", "www.google.com" }.Select(target =>
await StartupLearningWarmup.RunAsync(async beginLearning => {
await _lifecycle.WaitAsync(cancellationToken);
try
{
await StopCoreAsync();
_baseConfigJson = configJson;
_tailnetFallbackConfigJson = preferred is not null ? original : tailnetFallbackConfigJson;
_preferredTailnetConfigJson = preferred;
_routeMode = routeMode;
_nodeSlug = nodeSlug;
await StartCoreAsync(cancellationToken, routeMode == "smart" ? beginLearning : null);
}
catch
{
await StopCoreAsync().ConfigureAwait(false);
throw;
}
finally { _lifecycle.Release(); }
if (_routeMode == "smart") StatusMessage?.Invoke("正在验证本地直连与代理路径…");
}, warmupToken =>
// Keep the same targets, direct/proxy proof and lifecycle-gated
// commits. Only their read-only transport work overlaps DNS setup.
Task.WhenAll(new[] { "chatgpt.com", "api.openai.com", "www.google.com" }.Select(target =>
ScheduleLearningAsync(new LearningObservation { Target=target, Port=443, AccessKind="http",
Node=_nodeSlug, Scope=PrivateAuxiliaryRuntime.IsPrivate(_baseConfigJson ?? "{}") ? "private_auxiliary" : "public" }, warmup.Token)));
}
Node=_nodeSlug, Scope=PrivateAuxiliaryRuntime.IsPrivate(_baseConfigJson ?? "{}") ? "private_auxiliary" : "public" }, warmupToken))),
cancellationToken);
}
internal async Task StopAsync()
@@ -262,7 +257,8 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt
finally { _lifecycle.Release(); }
}
private async Task StartCoreAsync(CancellationToken cancellationToken)
private async Task StartCoreAsync(CancellationToken cancellationToken,
Action<CancellationToken>? beginStartupLearning = null)
{
EnsureRuntime();
if (string.IsNullOrWhiteSpace(_baseConfigJson)) throw new InvalidOperationException("线路配置为空。");
@@ -365,6 +361,7 @@ internal sealed class XrayManager : IDisposable, IAsyncDisposable, IHandoverRunt
// Apply 0.2.5 routing first, then wait until Windows has completed
// DAD before applications can use the tunnel's DNS/IPv4 path.
await TunRouting.WaitForAdapterAsync(cancellationToken, requireIpv4Ready: true);
beginStartupLearning?.Invoke(_learningEpoch.Token);
await ProxyDnsPolicy.EnableAsync(_baseConfigJson, cancellationToken);
StatusMessage?.Invoke("正在等待 Windows 网络与 DNS 就绪…");
await WaitForDnsReadyAsync(cancellationToken);