Merge 561419eb7794291a4fc8ff9eb8ceccc377333623 into 4290ea753912378913b1f3f54e0fc5720afeda5d

This commit is contained in:
Roland 2026-08-10 00:00:14 -07:00 committed by GitHub
commit 60720c6616
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 3 deletions

View File

@ -34,7 +34,7 @@ export function ipv4CidrRange(cidr, includeNetworkInfo, enumerateAddresses, allo
ip2 = ip1 | ~mask; ip2 = ip1 | ~mask;
if (includeNetworkInfo) { if (includeNetworkInfo) {
output += "Network: " + ipv4ToStr(network) + "\n"; output += "Network: " + ipv4ToStr(ip1) + "\n";
output += "CIDR: " + cidrRange + "\n"; output += "CIDR: " + cidrRange + "\n";
output += "Mask: " + ipv4ToStr(mask) + "\n"; output += "Mask: " + ipv4ToStr(mask) + "\n";
output += "Range: " + ipv4ToStr(ip1) + " - " + ipv4ToStr(ip2) + "\n"; output += "Range: " + ipv4ToStr(ip1) + " - " + ipv4ToStr(ip2) + "\n";
@ -88,8 +88,8 @@ export function ipv6CidrRange(cidr, includeNetworkInfo) {
} }
if (includeNetworkInfo) { if (includeNetworkInfo) {
output += "Network: " + ipv6ToStr(network) + "\n"; output += "Network: " + ipv6ToStr(ip1) + "\n";
output += "Shorthand: " + ipv6ToStr(network, true) + "\n"; output += "Shorthand: " + ipv6ToStr(ip1, true) + "\n";
output += "CIDR: " + cidrRange + "\n"; output += "CIDR: " + cidrRange + "\n";
output += "Mask: " + ipv6ToStr(mask) + "\n"; output += "Mask: " + ipv6ToStr(mask) + "\n";
output += "Range: " + ipv6ToStr(ip1) + " - " + ipv6ToStr(ip2) + "\n"; output += "Range: " + ipv6ToStr(ip1) + " - " + ipv6ToStr(ip2) + "\n";

View File

@ -19,6 +19,28 @@ TestRegister.addTests([
}, },
], ],
}, },
{
name: "Parse IPv4 CIDR with host bits set",
input: "10.0.0.1/30",
expectedOutput: "Network: 10.0.0.0\nCIDR: 30\nMask: 255.255.255.252\nRange: 10.0.0.0 - 10.0.0.3\nTotal addresses in range: 4\n\n10.0.0.0\n10.0.0.1\n10.0.0.2\n10.0.0.3",
recipeConfig: [
{
"op": "Parse IP range",
"args": [true, true, false]
},
],
},
{
name: "Parse IPv6 CIDR with host bits set",
input: "2404:6800:4001:0001:0000:0000:0000:0000/48",
expectedOutput: "Network: 2404:6800:4001:0000:0000:0000:0000:0000\nShorthand: 2404:6800:4001::\nCIDR: 48\nMask: ffff:ffff:ffff:0000:0000:0000:0000:0000\nRange: 2404:6800:4001:0000:0000:0000:0000:0000 - 2404:6800:4001:ffff:ffff:ffff:ffff:ffff\nTotal addresses in range: 1.2089258196146292e+24\n\n",
recipeConfig: [
{
"op": "Parse IP range",
"args": [true, true, false]
},
],
},
{ {
name: "Parse IPv4 hyphenated", name: "Parse IPv4 hyphenated",
input: "10.0.0.0 - 10.0.0.3", input: "10.0.0.0 - 10.0.0.3",