Windows 0.3.0 clean next-generation source delta; no private history or other platform changes

This commit is contained in:
2026-10-22 05:43:39 +00:00
parent ac650ed51d
commit 366b3c5c9a
31 changed files with 2036 additions and 323 deletions
+30 -7
View File
@@ -17,18 +17,40 @@ internal static class TailnetTransport
&& value is not ("100.100.100.100" or "100.64.0.0" or "100.127.255.255");
internal static string? TryPrepare(ConfigResponse response, bool allowKnownEndpoints = false)
=> TryPrepare(response, out _, allowKnownEndpoints);
internal static string? TryPrepare(ConfigResponse response, out string reason, bool allowKnownEndpoints = false)
{
var endpoint = response.TailscaleEndpoint ?? KnownTailnetEndpoints.Resolve(response, allowKnownEndpoints);
if (endpoint is null || endpoint.Contract != 1 || endpoint.NodeSlug != response.Node.Slug
|| string.IsNullOrWhiteSpace(endpoint.NodeSlug) || !IsTailnetAddress(endpoint.Address)
|| endpoint.Port is < 1 or > 65535 || response.ConfigContract != 2
|| response.ConnectionScope is not ("" or "public") || response.RouteMode is not ("smart" or "global"))
return null;
reason = "explicit_endpoint";
var endpoint = response.TailscaleEndpoint;
if (endpoint is null)
{
if (response.HasTailscaleEndpoint) { reason = "explicit_endpoint_disabled"; return null; }
endpoint = KnownTailnetEndpoints.Resolve(response, allowKnownEndpoints, out reason);
if (endpoint is null) return null;
}
var source = reason;
reason = "endpoint_contract_unsupported";
if (endpoint.Contract != 1) return null;
reason = "endpoint_node_mismatch";
if (endpoint.NodeSlug != response.Node.Slug || string.IsNullOrWhiteSpace(endpoint.NodeSlug)) return null;
reason = "endpoint_address_invalid";
if (!IsTailnetAddress(endpoint.Address)) return null;
reason = "endpoint_port_invalid";
if (endpoint.Port is < 1 or > 65535) return null;
reason = "config_contract_unsupported";
if (response.ConfigContract != 2) return null;
reason = "scope_unsupported";
if (response.ConnectionScope is not ("" or "public")) return null;
reason = "route_mode_unsupported";
if (response.RouteMode is not ("smart" or "global")) return null;
try
{
var root = JsonNode.Parse(response.GetRuntimeConfigJson())!.AsObject();
reason = "config_scope_or_marker_invalid";
if (PrivateAuxiliaryRuntime.IsPrivate(root) || root.ContainsKey(Marker)) return null;
var proxy = Proxy(root);
reason = "proxy_identity_unsupported";
if (proxy is null) return null;
var server = proxy["settings"]!["vnext"]![0]!.AsObject();
// Preserve users/flow/encryption/Reality key/SNI/shortId and all rules.
@@ -36,10 +58,11 @@ internal static class TailnetTransport
server["address"] = endpoint.Address;
server["port"] = endpoint.Port;
root[Marker] = new JsonObject { ["address"] = endpoint.Address, ["port"] = endpoint.Port };
reason = source;
return root.ToJsonString();
}
catch (Exception e) when (e is System.Text.Json.JsonException or InvalidOperationException or FormatException)
{ return null; } // Invalid optional metadata never breaks the original ingress.
{ reason = "config_invalid"; return null; } // Invalid optional metadata never breaks the original ingress.
}
internal static JsonObject? Proxy(JsonObject root)