Update VPN client connection flow
Build and Deploy Gateway / build-and-push (push) Successful in 15s
Build and Deploy Gateway / deploy (push) Successful in 13s

This commit is contained in:
2026-08-07 21:19:33 +03:00
parent 0c376c72aa
commit 0a4a6d9443
16 changed files with 771 additions and 342 deletions
+38 -1
View File
@@ -92,7 +92,7 @@ test('connectivity diagnostics skips VPN probes when sing-box is off', async ()
assert.equal(calls.some((args) => args.includes('--proxy')), false);
});
test('connectivity diagnostics keeps a partial snapshot and falls back when one IP source fails', async () => {
test('connectivity diagnostics keeps every IP source in a partial snapshot', async () => {
const execute = async (args) => {
const url = args.at(-1);
if (url.includes('cloudflare')) {
@@ -112,5 +112,42 @@ test('connectivity diagnostics keeps a partial snapshot and falls back when one
'cloudflare',
'ipify',
'aws',
'icanhazip',
'ifconfig-me',
'yandex-internet',
]);
});
test('connectivity diagnostics pins public custom services and rejects private destinations', async () => {
const calls = [];
const execute = async (args) => {
calls.push(args);
const url = args.at(-1);
if (url.includes('cloudflare')) return response('ip=198.51.100.10\n');
if (url.includes('api6')) return response('', { exitcode: 6, http_code: 0, errormsg: 'resolve failed' });
if (url.includes('ipify')) return response('198.51.100.10');
return response();
};
const lookup = async (hostname) => hostname === 'router.local'
? [{ address: '192.168.50.1', family: 4 }]
: [{ address: '93.184.216.34', family: 4 }];
const result = await createConnectivityDiagnosticsService({ proxyPort: 18080, execute, lookup })
.run({
vpnAvailable: false,
services: [
{ id: 'custom-public', label: 'Example', url: 'https://example.com/status' },
{ id: 'custom-private', label: 'Router', url: 'https://router.local/' },
],
});
const publicCall = calls.find((args) => args.at(-1) === 'https://example.com/status');
assert.ok(publicCall);
assert.equal(publicCall.includes('--location'), false);
assert.deepEqual(publicCall.slice(publicCall.indexOf('--resolve'), publicCall.indexOf('--resolve') + 2), [
'--resolve',
'example.com:443:93.184.216.34',
]);
assert.equal(calls.some((args) => args.at(-1) === 'https://router.local/'), false);
assert.equal(result.direct.sites.find((site) => site.id === 'custom-private').stage, 'validation');
assert.equal(result.assessment.comparisons.some((item) => item.id === 'custom-public'), true);
});