Integrate Xray 26.9.9 with the sing-box system tunnel and verify Windows routes during health checks. Improve endpoint selection, network recovery, subscription refresh deadlines, diagnostics, packaging, and regression coverage.
46 lines
2.2 KiB
C#
46 lines
2.2 KiB
C#
using QVPN.Core;
|
|
|
|
internal static class SystemTunnelProbeTests
|
|
{
|
|
public static async Task RunAsync(Func<string, Action, Task> test)
|
|
{
|
|
await test("An Up VPN adapter cannot hide a physical IPv4 route", () =>
|
|
{
|
|
var state = SystemTunnelProbe.Evaluate(true, 14, 14, new(0, 9), new(0, 14));
|
|
Check(state.AdapterAvailable && !state.Ipv4RoutedThroughTunnel && !state.Healthy);
|
|
});
|
|
await test("IPv6 bypass is rejected even when IPv4 uses the VPN", () =>
|
|
{
|
|
var state = SystemTunnelProbe.Evaluate(true, 14, 14, new(0, 14), new(0, 9));
|
|
Check(state.Ipv4RoutedThroughTunnel && state.Ipv6RoutedThroughTunnel == false && !state.Healthy);
|
|
});
|
|
await test("A missing IPv6 route permits a verified IPv4-only network", () =>
|
|
{
|
|
foreach (uint error in new uint[] {1168, 1231})
|
|
{
|
|
var state = SystemTunnelProbe.Evaluate(true, 14, 0, new(0, 14), new(error, 0));
|
|
Check(state.Healthy && state.Ipv6RoutedThroughTunnel is null);
|
|
}
|
|
Check(SystemTunnelProbe.Evaluate(true, 14, 0, new(0, 14), null).Healthy);
|
|
});
|
|
await test("Unknown route errors and a missing adapter never report a healthy VPN", () =>
|
|
{
|
|
Check(!SystemTunnelProbe.Evaluate(true, 14, 14, new(0, 14), new(5, 0)).Healthy);
|
|
Check(!SystemTunnelProbe.Evaluate(true, 14, 14, new(0, 14), new(232, 0)).Healthy);
|
|
Check(!SystemTunnelProbe.Evaluate(true, 14, 14, new(0, 14), new(1232, 0)).Healthy);
|
|
Check(!SystemTunnelProbe.Evaluate(true, 14, 14, new(5, 0), new(0, 14)).Healthy);
|
|
Check(!SystemTunnelProbe.Evaluate(false, 14, 14, new(0, 14), new(0, 14)).Healthy);
|
|
Check(!SystemTunnelProbe.Evaluate(true, 0, 0, new(0, 0), new(0, 0)).Healthy);
|
|
});
|
|
await test("Both Windows route families can belong to the verified VPN", () =>
|
|
{
|
|
Check(SystemTunnelProbe.Evaluate(true, 14, 14, new(0, 14), new(0, 14)).Healthy);
|
|
});
|
|
}
|
|
|
|
private static void Check(bool condition)
|
|
{
|
|
if (!condition) throw new InvalidOperationException("System tunnel route verification failed.");
|
|
}
|
|
}
|