Windows 0.3.6 runtime preflight and update download reliability source delta; connection fixes retained; no private history or other platform changes
This commit is contained in:
@@ -203,6 +203,52 @@ internal static class TailnetTransportSelfTest
|
||||
r["config"]!["outbounds"]![0]!["settings"]!["vnext"]![0]!["port"] = 11083;
|
||||
}), true)!;
|
||||
checks["known_silicon_exact_mapping"] = Host(silicon) == "100.64.0.3" && TailnetTransport.Port(silicon) == 11083;
|
||||
ConfigResponse NewYork(Action<JsonObject>? change = null) => Known(r => {
|
||||
r["node"]!["slug"] = "racknerd-newyork-004"; r["node"]!["name"] = "VPN004";
|
||||
r["config"]!["outbounds"]![0]!["settings"]!["vnext"]![0]!["address"] = "004.vpn.example.invalid";
|
||||
r["config"]!["outbounds"]![0]!["settings"]!["vnext"]![0]!["port"] = 11084;
|
||||
change?.Invoke(r);
|
||||
});
|
||||
var newYork = NewYork();
|
||||
var newYorkOriginal = newYork.GetRuntimeConfigJson();
|
||||
var newYorkPrepared = TailnetTransport.TryPrepare(newYork, true);
|
||||
checks["known_newyork_exact_mapping"] = newYorkPrepared is not null
|
||||
&& Host(newYorkPrepared) == "100.64.0.44" && TailnetTransport.Port(newYorkPrepared) == 11084;
|
||||
checks["known_newyork_requires_mapping_permission"] = TailnetTransport.TryPrepare(newYork) is null;
|
||||
checks["known_newyork_same_authorized_fallback"] = newYorkPrepared is not null
|
||||
&& TailnetTransport.SameAuthorizedFallback(newYorkPrepared, newYorkOriginal);
|
||||
var newYorkRestored = newYorkPrepared is null ? null : JsonNode.Parse(newYorkPrepared)!.AsObject();
|
||||
if (newYorkRestored is not null)
|
||||
{
|
||||
newYorkRestored.Remove(TailnetTransport.Marker);
|
||||
newYorkRestored["outbounds"]![0]!["settings"]!["vnext"]![0]!["address"] = "004.vpn.example.invalid";
|
||||
newYorkRestored["outbounds"]![0]!["settings"]!["vnext"]![0]!["port"] = 11084;
|
||||
}
|
||||
checks["known_newyork_preserves_all_credentials_and_rules"] = newYorkRestored is not null
|
||||
&& JsonNode.DeepEquals(newYorkRestored, JsonNode.Parse(newYorkOriginal))
|
||||
&& newYork.GetRuntimeConfigJson() == newYorkOriginal;
|
||||
checks["known_newyork_changed_host_rejected"] = TailnetTransport.TryPrepare(NewYork(r =>
|
||||
r["config"]!["outbounds"]![0]!["settings"]!["vnext"]![0]!["address"] = "other.example.com"), true) is null;
|
||||
checks["known_newyork_changed_port_rejected"] = TailnetTransport.TryPrepare(NewYork(r =>
|
||||
r["config"]!["outbounds"]![0]!["settings"]!["vnext"]![0]!["port"] = 11083), true) is null;
|
||||
checks["known_newyork_changed_slug_rejected"] = TailnetTransport.TryPrepare(NewYork(r =>
|
||||
r["node"]!["slug"] = "unapproved-newyork"), true) is null;
|
||||
checks["known_newyork_explicit_null_disables_mapping"] = TailnetTransport.TryPrepare(NewYork(r => r["tailscale_endpoint"] = null), true) is null;
|
||||
checks["known_newyork_invalid_metadata_never_uses_mapping"] = TailnetTransport.TryPrepare(NewYork(r => r["tailscale_endpoint"] = new JsonObject()), true) is null;
|
||||
var newYorkExplicit = TailnetTransport.TryPrepare(NewYork(r => r["tailscale_endpoint"] = new JsonObject {
|
||||
["contract"] = 1, ["node_slug"] = "racknerd-newyork-004", ["address"] = "100.65.1.9", ["port"] = 2345
|
||||
}), true);
|
||||
checks["known_newyork_server_metadata_remains_authoritative"] = newYorkExplicit is not null
|
||||
&& Host(newYorkExplicit) == "100.65.1.9" && TailnetTransport.Port(newYorkExplicit) == 2345;
|
||||
var newYorkStarts = new List<string>(); var newYorkStops = 0; var newYorkProbes = 0;
|
||||
var newYorkSelected = await NodeTransportConnector.ConnectAsync(newYork, new(),
|
||||
(json, _) => { newYorkStarts.Add(json); return Task.CompletedTask; },
|
||||
() => { newYorkStops++; return Task.CompletedTask; },
|
||||
_ => { newYorkProbes++; return Task.FromResult(false); }, _ => { }, _ => { }, () => tick, CancellationToken.None,
|
||||
allowKnownEndpoints: true, endpointProbe: (address, port, _) => Task.FromResult(address == "100.64.0.44" && port == 11084));
|
||||
checks["known_newyork_failed_proxy_falls_back_only_same_authorized_node"] = !newYorkSelected
|
||||
&& newYorkStarts.Count == 2 && Host(newYorkStarts[0]) == "100.64.0.44"
|
||||
&& newYorkStarts[1] == newYorkOriginal && newYorkStops == 1 && newYorkProbes == 1;
|
||||
var future = TailnetTransport.TryPrepare(Known(r => r["tailscale_endpoint"] = new JsonObject {
|
||||
["contract"] = 1, ["node_slug"] = "aliyun-tokyo-002", ["address"] = "100.65.1.9", ["port"] = 2345
|
||||
}), true)!;
|
||||
|
||||
Reference in New Issue
Block a user