Add IP routing rules and fix gRPC buffer retention
This commit is contained in:
@@ -534,6 +534,7 @@ setInterval(() => {}, 60_000);
|
||||
rulesContractVersion: 2,
|
||||
rules: [
|
||||
{ type: 'domain_suffix', value: 'ru', enabled: false, outbound: 'direct' },
|
||||
{ type: 'ip_cidr', value: ' 203.0.113.25 ', enabled: true, outbound: 'direct' },
|
||||
{ type: 'domain', value: 'https://Example.com/private?q=1', enabled: true, outbound: 'vpn' },
|
||||
{ type: 'domain_suffix', value: '*.Example.org', enabled: true, outbound: 'direct' },
|
||||
],
|
||||
@@ -541,12 +542,13 @@ setInterval(() => {}, 60_000);
|
||||
rulesRevision = routed.state.route.localRulesRevision;
|
||||
assert.deepEqual(routed.state.route.localRules, [
|
||||
{ type: 'domain_suffix', value: 'ru', enabled: false, outbound: 'direct' },
|
||||
{ type: 'ip_cidr', value: '203.0.113.25', enabled: true, outbound: 'direct' },
|
||||
{ type: 'domain', value: 'example.com', enabled: true, outbound: 'vpn' },
|
||||
{ type: 'domain_suffix', value: 'example.org', enabled: true, outbound: 'direct' },
|
||||
]);
|
||||
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, 4), [
|
||||
assert.deepEqual(JSON.parse(fs.readFileSync(path.join(dir, 'sing-box-config.json'))).route.rules.slice(0, 5), [
|
||||
{
|
||||
inbound: ['mixed-in', 'diagnostics-vpn-in'],
|
||||
action: 'sniff',
|
||||
@@ -554,6 +556,7 @@ setInterval(() => {}, 60_000);
|
||||
timeout: '1s',
|
||||
},
|
||||
{ inbound: ['diagnostics-vpn-in'], outbound: testServerId },
|
||||
{ ip_cidr: ['203.0.113.25'], outbound: 'direct' },
|
||||
{ domain: ['example.com'], outbound: testServerId },
|
||||
{ domain_suffix: ['example.org'], outbound: 'direct' },
|
||||
]);
|
||||
@@ -606,6 +609,7 @@ setInterval(() => {}, 60_000);
|
||||
for (const rules of [
|
||||
[{ type: 'domain', value: 'missing.example', enabled: true }],
|
||||
[{ type: 'domain', value: 'unknown.example', enabled: true, outbound: 'block' }],
|
||||
[{ type: 'ip_cidr', value: '256.0.0.1', enabled: true, outbound: 'direct' }],
|
||||
]) {
|
||||
const rejected = await rawRequest(port, '/api/route-rules/v2', 'PUT', {
|
||||
expectedRulesRevision: rulesRevision,
|
||||
|
||||
Reference in New Issue
Block a user