Enable connectivity diagnostics in Connect mode
Build and Deploy Gateway / build-and-push (push) Successful in 13s
Build and Deploy Gateway / deploy (push) Successful in 13s

This commit is contained in:
2026-08-07 21:43:09 +03:00
parent 70cc221f34
commit d32bc14108
12 changed files with 60 additions and 31 deletions
@@ -1,10 +1,14 @@
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import test from 'node:test';
import {
createConnectivityDiagnosticsService,
CURL_META_MARKER,
} from '../../src/server/services/connectivityDiagnosticsService.js';
const server = fs.readFileSync(path.resolve(import.meta.dirname, '../../src/server/index.js'), 'utf8');
function response(body = '', overrides = {}) {
return {
exitCode: 0,
@@ -48,6 +52,11 @@ test('connectivity diagnostics force separate direct and VPN paths', async () =>
assert.ok(calls.some((args) => args.includes('--proxy') && args.includes('http://127.0.0.1:18080')));
});
test('connectivity diagnostics endpoint is available in Connect and Gateway', () => {
assert.match(server, /const localConnectivityDiagnostics = !remoteDataplane/);
assert.doesNotMatch(server, /settings\.appMode !== 'gateway'[\s\S]{0,120}ENDPOINT_NOT_FOUND/);
});
test('connectivity diagnostics reports a likely direct restriction without claiming its owner', async () => {
const attempts = new Map();
const execute = async (args) => {
+8 -2
View File
@@ -30,9 +30,14 @@ test('client exposes one local proxy and routes local exceptions before the sele
],
});
assert.deepEqual(config.inbounds.map((inbound) => inbound.tag), ['mixed-in']);
assert.deepEqual(config.inbounds.map((inbound) => inbound.tag), [
'mixed-in',
'diagnostics-vpn-in',
]);
assert.equal(config.inbounds[0].listen_port, 8082);
assert.equal(config.inbounds[1].listen_port, 18080);
assert.deepEqual(config.route.rules, [
{ inbound: ['diagnostics-vpn-in'], outbound: 'test-vpn' },
{ domain_suffix: ['ru'], outbound: 'direct' },
{ domain: ['example.com'], outbound: 'direct' },
{ inbound: ['mixed-in'], outbound: 'test-vpn' },
@@ -48,9 +53,10 @@ test('client keeps its local proxy but routes directly when Harbor Gateway is ah
});
assert.deepEqual(config.route.rules, [
{ inbound: ['diagnostics-vpn-in'], outbound: 'test-vpn' },
{ domain_suffix: ['ru'], outbound: 'direct' },
{ inbound: ['mixed-in'], outbound: 'direct' },
]);
assert.equal(config.route.final, 'direct');
assert.deepEqual(config.outbounds.map((outbound) => outbound.tag), ['direct', 'block']);
assert.deepEqual(config.outbounds.map((outbound) => outbound.tag), ['test-vpn', 'direct', 'block']);
});
+1 -1
View File
@@ -433,9 +433,9 @@ setInterval(() => {}, 60_000);
assert.equal(routed.state.route.localRulesPendingRestart, false);
assert.deepEqual(routed.state.route.activeLocalRules, routed.state.route.localRules);
assert.deepEqual(JSON.parse(fs.readFileSync(path.join(dir, 'sing-box-config.json'))).route.rules.slice(0, 3), [
{ inbound: ['diagnostics-vpn-in'], outbound: testServerId },
{ domain: ['example.com'], outbound: 'direct' },
{ domain_suffix: ['example.org'], outbound: 'direct' },
{ inbound: ['mixed-in'], outbound: testServerId },
]);
await mutation('/api/singbox/stop');