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
+25 -8
View File
@@ -13,11 +13,11 @@ namespace UCVL.VPNPlus;
// LAN scanning, GPS, employee-office lookup or Tailscale process detection.
internal static class PrivateAuxiliaryRouting
{
internal const string JinanAddress = "192.168.50.111";
internal const string PhoneAddress = "192.168.50.170";
internal const string PhoneTailnetAddress = "100.64.0.4";
internal const string PublicPhoneAddress = "192.0.2.1";
internal const string PublicPhoneHost = "vpn.example.invalid";
internal const string JinanAddress = "172.16.0.111";
internal const string PhoneAddress = "192.168.8.170";
internal const string PhoneTailnetAddress = "100.84.199.104";
internal const string PublicPhoneAddress = "59.110.91.17";
internal const string PublicPhoneHost = "vpn.toplc.cn";
internal static bool IsRegisteredEndpoint(string? address) =>
address is JinanAddress or PhoneAddress or PhoneTailnetAddress or PublicPhoneAddress or PublicPhoneHost;
internal static bool ValidEndpoint(PrivateAuxiliaryNode node) =>
@@ -96,19 +96,36 @@ internal static class PrivateAuxiliaryRouting
internal static async Task<IReadOnlyList<PrivateAuxiliaryNode>> RankForSelectionAsync(ConnectionSelection selection,
IReadOnlyList<PrivateAuxiliaryNode> grants, IReadOnlySet<string> coolingDown, bool existingCoreRunning,
Func<PrivateAuxiliaryNode, CancellationToken, Task<long?>> measure, CancellationToken token)
Func<PrivateAuxiliaryNode, CancellationToken, Task<long?>> measure, CancellationToken token,
bool tailnetOnly = false)
{
token.ThrowIfCancellationRequested();
if (existingCoreRunning && !selection.Manual) return [];
var authorized = selection.Manual ? grants.Where(n => n.Slug == selection.NodeSlug) : grants;
var expanded = authorized.SelectMany(n => n.ConnectionEndpoints.Count == 0 ? new[] { n }
: n.ConnectionEndpoints.Take(3).Select(n.WithEndpoint)).ToArray();
var expanded = ExpandEndpoints(authorized)
.Where(n => !tailnetOnly || TailnetTransport.IsTailnetAddress(n.ProbeIpv4)).ToArray();
var ranked = await RankByLatencyAsync(expanded, selection.Manual ? new HashSet<string>() : coolingDown, measure, token);
if (selection.Manual && expanded.Length > 0 && ranked.Count == 0)
throw new InvalidOperationException("所选节点内网和域名入口均不可达,未切换其他节点。");
return ranked;
}
internal static IReadOnlyList<PrivateAuxiliaryNode> ManualEndpoints(string slug,
IReadOnlyList<PrivateAuxiliaryNode> grants, DateTimeOffset now)
{
var selected = grants.Where(n => n.Slug == slug).ToArray();
var endpoints = ExpandEndpoints(selected.Where(n => n.ExpiresAt > now)).Where(ValidEndpoint)
.OrderBy(n => TailnetTransport.IsTailnetAddress(n.ProbeIpv4) ? 0 : n.ProbeIpv4 == PublicPhoneAddress ? 2 : 1)
.ToArray();
if (selected.Length != 0 && endpoints.Length == 0)
throw new InvalidOperationException("所选节点没有有效授权入口,请刷新账号信息后重试。");
return endpoints;
}
private static IEnumerable<PrivateAuxiliaryNode> ExpandEndpoints(IEnumerable<PrivateAuxiliaryNode> grants) =>
grants.SelectMany(n => n.ConnectionEndpoints.Count == 0 ? new[] { n }
: n.ConnectionEndpoints.Take(3).Select(n.WithEndpoint));
internal static PrivateAuxiliaryNode ForRenewal(PrivateAuxiliaryNode grant, PrivateAuxiliaryNode current)
{
if (grant.Slug != current.Slug || !ValidEndpoint(current))