feat(ipintelligence): add canonical RDAP CIDR coverage and derive CIDRs from IPv4 start/end ranges

This commit is contained in:
2026-04-26 20:45:47 +00:00
parent 5331a3c2ce
commit 3e86e99d4f
5 changed files with 139 additions and 11 deletions
+31
View File
@@ -41,6 +41,37 @@ tap.test('should get IP intelligence for 1.1.1.1 (Cloudflare)', async () => {
// Note: 1.1.1.1 is anycast — city-level geo may be null in GeoLite2
});
tap.test('should derive a single CIDR from RDAP start/end ranges', async () => {
const intelligence = new smartnetwork.IpIntelligence();
const result = (intelligence as any).parseRdapNetworkInfo({
startAddress: '203.0.113.0',
endAddress: '203.0.113.255',
});
expect(result).toEqual({
networkRange: '203.0.113.0/24',
networkCidrs: ['203.0.113.0/24'],
});
});
tap.test('should expose CIDRs for RDAP ranges that need multiple prefixes', async () => {
const intelligence = new smartnetwork.IpIntelligence();
const result = (intelligence as any).parseRdapNetworkInfo({
startAddress: '203.0.113.5',
endAddress: '203.0.113.10',
});
expect(result).toEqual({
networkRange: '203.0.113.5 - 203.0.113.10',
networkCidrs: [
'203.0.113.5/32',
'203.0.113.6/31',
'203.0.113.8/31',
'203.0.113.10/32',
],
});
});
tap.test('should get IP intelligence for own public IP', async () => {
const ips = await testSmartNetwork.getPublicIps();
if (ips.v4) {