Publish reviewed history-free open-source snapshot (2026-10-12)
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
namespace UCVL.VPNPlus;
|
||||
|
||||
// A manual selection is never allowed to fall back to automatic dispatch.
|
||||
internal sealed record ConnectionSelection(string NodeSlug, bool Manual)
|
||||
{
|
||||
internal static ConnectionSelection Create(bool manual, string? selectedSlug, IEnumerable<string> authorizedSlugs)
|
||||
{
|
||||
if (!manual) return new("auto", false);
|
||||
if (string.IsNullOrWhiteSpace(selectedSlug) || selectedSlug == "auto"
|
||||
|| !authorizedSlugs.Contains(selectedSlug, StringComparer.Ordinal))
|
||||
throw new InvalidOperationException("请选择当前账号有权使用的节点;节点可能已下线或授权已变更。");
|
||||
return new(selectedSlug, true);
|
||||
}
|
||||
|
||||
internal int Attempts(int availableCount) => Manual ? 1 : Math.Min(availableCount, 8);
|
||||
|
||||
internal void ValidateResponse(string actualSlug)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(actualSlug) || actualSlug == "auto"
|
||||
|| (Manual && !string.Equals(NodeSlug, actualSlug, StringComparison.Ordinal)))
|
||||
throw new InvalidOperationException("服务器返回的节点与连接选择不一致,已拒绝连接。");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user