Add enabled local routing rules and gateway version reporting
This commit is contained in:
@@ -169,10 +169,9 @@ setInterval(() => {}, 60_000);
|
||||
});
|
||||
assertStateSnapshot(initial);
|
||||
assert.equal(initial.selection.appliedServerId, 'test-vpn');
|
||||
assert.deepEqual(initial.route.localRules, {
|
||||
builtIn: [{ type: 'domain_suffix', value: 'ru' }],
|
||||
custom: [],
|
||||
});
|
||||
assert.deepEqual(initial.route.localRules, [
|
||||
{ type: 'domain_suffix', value: 'ru', enabled: true },
|
||||
]);
|
||||
assert.equal(JSON.stringify(initial).includes(subscriptionUrl), false);
|
||||
const stateKeys = Object.keys(initial).sort();
|
||||
let revision = initial.revision;
|
||||
@@ -242,18 +241,20 @@ setInterval(() => {}, 60_000);
|
||||
const routed = await mutation('/api/route-rules', 'PUT', {
|
||||
expectedRevision: rulesRevision,
|
||||
rules: [
|
||||
{ type: 'domain', value: 'https://Example.com/private?q=1' },
|
||||
{ type: 'domain_suffix', value: '*.Example.org' },
|
||||
{ type: 'domain_suffix', value: 'ru', enabled: false },
|
||||
{ type: 'domain', value: 'https://Example.com/private?q=1', enabled: true },
|
||||
{ type: 'domain_suffix', value: '*.Example.org', enabled: true },
|
||||
],
|
||||
});
|
||||
assert.deepEqual(routed.state.route.localRules.custom, [
|
||||
{ type: 'domain', value: 'example.com' },
|
||||
{ type: 'domain_suffix', value: 'example.org' },
|
||||
assert.deepEqual(routed.state.route.localRules, [
|
||||
{ type: 'domain_suffix', value: 'ru', enabled: false },
|
||||
{ type: 'domain', value: 'example.com', enabled: true },
|
||||
{ type: 'domain_suffix', value: 'example.org', enabled: true },
|
||||
]);
|
||||
assert.deepEqual(JSON.parse(fs.readFileSync(path.join(dir, 'sing-box-config.json'))).route.rules.slice(0, 3), [
|
||||
{ domain_suffix: ['ru'], outbound: 'direct' },
|
||||
{ domain: ['example.com'], outbound: 'direct' },
|
||||
{ domain_suffix: ['example.org'], outbound: 'direct' },
|
||||
{ inbound: ['mixed-in'], outbound: 'test-vpn' },
|
||||
]);
|
||||
|
||||
const invalidRules = await rawRequest(port, '/api/route-rules', 'PUT', {
|
||||
@@ -270,7 +271,7 @@ setInterval(() => {}, 60_000);
|
||||
});
|
||||
assert.equal(staleRules.response.status, 409);
|
||||
assert.equal(staleRules.payload.error.code, 'STATE_CONFLICT');
|
||||
assert.deepEqual((await request(port, '/api/state')).route.localRules.custom, routed.state.route.localRules.custom);
|
||||
assert.deepEqual((await request(port, '/api/state')).route.localRules, routed.state.route.localRules);
|
||||
|
||||
const workingConfig = fs.readFileSync(path.join(dir, 'sing-box-config.json'), 'utf8');
|
||||
fs.writeFileSync(singboxPath, `#!/usr/bin/env node
|
||||
@@ -291,7 +292,7 @@ setInterval(() => {}, 60_000);
|
||||
assert.equal(failedRules.response.status, 422);
|
||||
assert.equal(failedRules.payload.error.code, 'CONFIG_INVALID');
|
||||
const rolledBack = await request(port, '/api/state');
|
||||
assert.deepEqual(rolledBack.route.localRules.custom, routed.state.route.localRules.custom);
|
||||
assert.deepEqual(rolledBack.route.localRules, routed.state.route.localRules);
|
||||
assert.equal(rolledBack.connection.process, 'running');
|
||||
assert.equal(fs.readFileSync(path.join(dir, 'sing-box-config.json'), 'utf8'), workingConfig);
|
||||
revision = rolledBack.revision;
|
||||
@@ -317,7 +318,7 @@ if (process.argv[2] === 'check') {
|
||||
const forgotten = await mutation('/api/subscription', 'DELETE');
|
||||
assert.equal(forgotten.state.subscription.status, 'missing');
|
||||
assert.equal(forgotten.state.servers.length, 0);
|
||||
assert.deepEqual(forgotten.state.route.localRules.custom, routed.state.route.localRules.custom);
|
||||
assert.deepEqual(forgotten.state.route.localRules, routed.state.route.localRules);
|
||||
assert.deepEqual((await stateResponse('/api/servers/ping-all')).results, []);
|
||||
|
||||
const missingConfig = await rawRequest(port, '/api/singbox/restart', 'POST');
|
||||
|
||||
Reference in New Issue
Block a user