2026-10-22 05:43:39 +00:00
|
|
|
namespace UCVL.VPNPlus;
|
|
|
|
|
|
|
|
|
|
internal sealed partial class MainForm
|
|
|
|
|
{
|
2026-11-03 15:15:23 +00:00
|
|
|
private Task<IReadOnlyList<PlannedTransport>> PlanTransportsAsync(ConnectionSelection selection,
|
2026-10-22 05:43:39 +00:00
|
|
|
IReadOnlyList<PrivateAuxiliaryNode> rankedPrivate, string routeMode, CancellationToken token)
|
|
|
|
|
{
|
2026-11-03 15:15:23 +00:00
|
|
|
token.ThrowIfCancellationRequested();
|
|
|
|
|
return Task.FromResult(TransportPlan.Create(selection, rankedPrivate, routeMode, _publicNodeCount));
|
|
|
|
|
}
|
2026-10-22 05:43:39 +00:00
|
|
|
|
2026-11-03 15:15:23 +00:00
|
|
|
private IAsyncEnumerable<PlannedTransport> ExpandTransportsAsync(IEnumerable<PlannedTransport> plans,
|
|
|
|
|
string routeMode, CancellationToken token) => TransportPlan.ExpandAsync(plans,
|
|
|
|
|
dispatchToken => LoadDispatchedTransportsAsync(routeMode, dispatchToken), token);
|
|
|
|
|
|
|
|
|
|
private async Task<IReadOnlyList<PlannedTransport>> LoadDispatchedTransportsAsync(string routeMode, CancellationToken token)
|
|
|
|
|
{
|
2026-10-27 02:00:33 +00:00
|
|
|
_statusDetail.Text = _tailnetPreference.DomainOnly ? "本次连接保持域名入口,不再自动切回内网。"
|
2026-11-03 15:15:23 +00:00
|
|
|
: "由后台自动分配节点,先尝试可达内网;不通则使用域名。";
|
|
|
|
|
var publicTailnet = await PublicTailnetSelection.RankDispatchedAsync(
|
2026-10-22 05:43:39 +00:00
|
|
|
_manualNodeCombo.Items.Cast<NodeInfo>().Where(n => n is not PrivateAuxiliaryNode), routeMode,
|
|
|
|
|
slug => _failedNodes.ContainsKey(slug) || !_tailnetPreference.MayTry(slug, Environment.TickCount64),
|
2026-11-03 15:15:23 +00:00
|
|
|
(excluded, probeToken) => _api.GetConfigAsync(_accessToken!, "auto", routeMode, probeToken, excluded),
|
2026-10-22 05:43:39 +00:00
|
|
|
TailnetTransport.ProbeEndpointAsync, token, allowKnownEndpoints: _knownTailnetAllowed,
|
|
|
|
|
diagnostic: (slug, reason) => AppPaths.WriteLog(new TransportDiagnostic("selection_probe", reason, slug).SafeMessage));
|
|
|
|
|
|
2026-11-03 15:15:23 +00:00
|
|
|
return publicTailnet.Select(c => new PlannedTransport(new(c.Response.Node.Slug, null), c.Response, true, true)).ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task<ConfigResponse?> ConfirmDispatchedTransportAsync(PlannedTransport planned,
|
|
|
|
|
string routeMode, CancellationToken token)
|
|
|
|
|
{
|
|
|
|
|
if (!planned.Dispatched || planned.Cached is null) return null;
|
|
|
|
|
return await PublicTailnetSelection.ConfirmDispatchAsync(new(planned.Cached, 0),
|
|
|
|
|
_manualNodeCombo.Items.Cast<NodeInfo>(), routeMode,
|
|
|
|
|
(excluded, dispatchToken) => _api.GetConfigAsync(_accessToken!, "auto", routeMode, dispatchToken, excluded), token);
|
2026-10-22 05:43:39 +00:00
|
|
|
}
|
|
|
|
|
}
|