Publish Zonghengjia Windows 0.3.13 client source
This commit is contained in:
@@ -12,7 +12,7 @@ internal sealed record ConnectionSelection(string NodeSlug, bool Manual)
|
||||
return new(selectedSlug, true);
|
||||
}
|
||||
|
||||
internal int Attempts(int availableCount) => Manual ? 1 : Math.Min(availableCount, 8);
|
||||
internal int Attempts(int availableCount) => Manual ? 1 : Math.Clamp(availableCount, 0, 3);
|
||||
|
||||
internal void ValidateResponse(string actualSlug)
|
||||
{
|
||||
@@ -20,4 +20,18 @@ internal sealed record ConnectionSelection(string NodeSlug, bool Manual)
|
||||
|| (Manual && !string.Equals(NodeSlug, actualSlug, StringComparison.Ordinal)))
|
||||
throw new InvalidOperationException("服务器返回的节点与连接选择不一致,已拒绝连接。");
|
||||
}
|
||||
|
||||
internal void ValidateConfig(ConnectionAttempt attempt, ConfigResponse response, string routeMode,
|
||||
IEnumerable<NodeInfo> authorizedNodes, IReadOnlyDictionary<string, DateTimeOffset> excludedNodes)
|
||||
{
|
||||
var slug = response.Node.Slug;
|
||||
ValidateResponse(slug);
|
||||
if ((attempt.Slug != "auto" && slug != attempt.Slug) || response.RouteMode != routeMode)
|
||||
throw new InvalidOperationException("服务器返回的节点或代理模式与请求不一致,已拒绝连接。");
|
||||
if (!attempt.IsPrivate && (response.ConnectionScope is not ("" or "public")
|
||||
|| !authorizedNodes.Any(n => n is not PrivateAuxiliaryNode && n.Slug == slug)))
|
||||
throw new InvalidOperationException("公共配置的节点不属于当前账号的授权范围,已拒绝连接。");
|
||||
if (attempt.Slug == "auto" && excludedNodes.ContainsKey(slug))
|
||||
throw new InvalidOperationException("后台返回了本次连接已排除的节点,未再次尝试。");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user