Add IP routing rules and fix gRPC buffer retention
Build and Deploy Gateway / build-and-push (push) Successful in 40s
Build and Deploy Gateway / deploy (push) Successful in 14s

This commit is contained in:
2026-10-30 22:57:46 +03:00
parent 4c58384056
commit 97791443c0
15 changed files with 210 additions and 30 deletions
+35
View File
@@ -49,3 +49,38 @@ test('legacy rules default to direct while order and first duplicate stay canoni
{ type: 'domain', value: 'api.example.com', enabled: true, outbound: 'vpn' },
]);
});
test('IP rules normalize exact IPv4 and IPv6 destinations and deduplicate equivalent IPv6', () => {
const rule = (value, outbound = 'direct') => ({ type: 'ip_cidr', value, enabled: true, outbound });
assert.deepEqual(normalizeRouteRules([
rule(' 203.0.113.25 '),
rule('2001:0DB8:0:0:0:0:0:1', 'vpn'),
rule('2001:db8::1'),
rule('::ffff:192.0.2.128'),
rule('0.0.0.0'),
rule('255.255.255.255'),
rule('::'),
], { strict: true }), [
rule('203.0.113.25'),
rule('2001:db8::1', 'vpn'),
rule('::ffff:c000:280'),
rule('0.0.0.0'),
rule('255.255.255.255'),
rule('::'),
]);
});
test('IP rules reject domains, URLs, ports, networks and ambiguous or invalid addresses', () => {
for (const value of [
'', 'example.com', 'https://203.0.113.25', '203.0.113.25:443',
'203.0.113.25/32', '2001:db8::/64', '203.0.113', '127.1', '2130706433',
'0x7f.0.0.1', '203.0.113.025', '256.0.0.1', '203.0.113.-1', '1.2.3.4.5',
'1.2.3. 4', '1.2.3.4,5.6.7.8', '1.2.3.4\n5.6.7.8',
'[2001:db8::1]', '[2001:db8::1]:443', 'fe80::1%en0', '2001:db8:::1',
'1:2:3:4:5:6:7', '1:2:3:4:5:6:7:8:9', '2001:db8::gg', '::ffff:256.0.0.1',
]) {
assert.throws(() => normalizeRouteRules([
{ type: 'ip_cidr', value, outbound: 'direct' },
], { strict: true }), TypeError, value);
}
});