Comparing version 0.2.6 to 0.2.7
@@ -167,3 +167,3 @@ /** | ||
mask1 = mask1 || 128; | ||
if (mask0 < 1 || mask1 < 1 || mask0 > 128 || mask1 > 128 || mask0 > mask1) { | ||
if (mask0 < 0 || mask1 < 0 || mask0 > 128 || mask1 > 128 || mask0 > mask1) { | ||
throw new Error('Invalid masks.'); | ||
@@ -202,3 +202,3 @@ } | ||
mask1 = mask1 || 128; | ||
if (mask0 < 1 || mask1 < 1 || mask0 > 128 || mask1 > 128 || mask0 > mask1) { | ||
if (mask0 < 0 || mask1 < 0 || mask0 > 128 || mask1 > 128 || mask0 > mask1) { | ||
throw new Error('Invalid masks.'); | ||
@@ -235,3 +235,3 @@ } | ||
mask1 = mask1 || 128; | ||
if (mask0 < 1 || mask1 < 1 || mask0 > 128 || mask1 > 128 || mask0 > mask1) { | ||
if (mask0 < 0 || mask1 < 0 || mask0 > 128 || mask1 > 128 || mask0 > mask1) { | ||
throw new Error('Invalid masks.'); | ||
@@ -266,3 +266,3 @@ } | ||
limit = limit || 1; | ||
if (mask0 < 1 || mask1 < 1 || mask0 > 128 || mask1 > 128 || mask0 > mask1) { | ||
if (mask0 < 0 || mask1 < 0 || mask0 > 128 || mask1 > 128 || mask0 > mask1) { | ||
throw new Error('Invalid masks.'); | ||
@@ -299,3 +299,3 @@ } | ||
mask *= 1; | ||
if (mask < 1 || mask > 128 || Math.floor(mask / 4) != mask / 4) { | ||
if (mask < 0 || mask > 128 || Math.floor(mask / 4) != mask / 4) { | ||
throw new Error('Invalid masks.'); | ||
@@ -302,0 +302,0 @@ } |
10
ip6.js
@@ -167,3 +167,3 @@ /** | ||
mask1 = mask1 || 128; | ||
if (mask0 < 1 || mask1 < 1 || mask0 > 128 || mask1 > 128 || mask0 > mask1) { | ||
if (mask0 < 0 || mask1 < 0 || mask0 > 128 || mask1 > 128 || mask0 > mask1) { | ||
throw new Error('Invalid masks.'); | ||
@@ -202,3 +202,3 @@ } | ||
mask1 = mask1 || 128; | ||
if (mask0 < 1 || mask1 < 1 || mask0 > 128 || mask1 > 128 || mask0 > mask1) { | ||
if (mask0 < 0 || mask1 < 0 || mask0 > 128 || mask1 > 128 || mask0 > mask1) { | ||
throw new Error('Invalid masks.'); | ||
@@ -235,3 +235,3 @@ } | ||
mask1 = mask1 || 128; | ||
if (mask0 < 1 || mask1 < 1 || mask0 > 128 || mask1 > 128 || mask0 > mask1) { | ||
if (mask0 < 0 || mask1 < 0 || mask0 > 128 || mask1 > 128 || mask0 > mask1) { | ||
throw new Error('Invalid masks.'); | ||
@@ -266,3 +266,3 @@ } | ||
limit = limit || 1; | ||
if (mask0 < 1 || mask1 < 1 || mask0 > 128 || mask1 > 128 || mask0 > mask1) { | ||
if (mask0 < 0 || mask1 < 0 || mask0 > 128 || mask1 > 128 || mask0 > mask1) { | ||
throw new Error('Invalid masks.'); | ||
@@ -299,3 +299,3 @@ } | ||
mask *= 1; | ||
if (mask < 1 || mask > 128 || Math.floor(mask / 4) != mask / 4) { | ||
if (mask < 0 || mask > 128 || Math.floor(mask / 4) != mask / 4) { | ||
throw new Error('Invalid masks.'); | ||
@@ -302,0 +302,0 @@ } |
@@ -95,2 +95,9 @@ /** | ||
it('should calculate the first and the last address of an IPv6 subnet.', function () { | ||
let n128 = ip6.rangeBigInt("::", 0, 128, false); | ||
expect(n128.start).toBe('0000:0000:0000:0000:0000:0000:0000:0000'); | ||
expect(n128.end).toBe('ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'); | ||
expect(n128.size).toBe('340282366920938463463374607431768211456'); | ||
}); | ||
it('should calculate the first and the last address of an IPv6 subnet.', function () { | ||
let n56 = ip6.range("2607:5300:60::", 48, 56); | ||
@@ -108,5 +115,6 @@ expect(n56.start).toBe('2607:5300:0060:0000:0000:0000:0000:0000'); | ||
it('should generate a PTR record for DNS zone file.', function () { | ||
let ptr = ip6.ptr("2607:5300:60:1234:cafe:babe:dead:beef", 64); | ||
expect(ptr).toBe('f.e.e.b.d.a.e.d.e.b.a.b.e.f.a.c'); | ||
expect(ip6.ptr("2607:5300:60:1234:cafe:babe:dead:beef", 64)).toBe('f.e.e.b.d.a.e.d.e.b.a.b.e.f.a.c'); | ||
expect(ip6.ptr("2607:5300:60:1234:cafe:babe:dead:beef", 128)).toBe(''); | ||
expect(ip6.ptr("2607:5300:60:1234:cafe:babe:dead:beef", 0)).toBe('f.e.e.b.d.a.e.d.e.b.a.b.e.f.a.c.4.3.2.1.0.6.0.0.0.0.3.5.7.0.6.2'); | ||
}); | ||
}); |
{ | ||
"name": "ip6", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"description": "IPv6 address helper utilities.", | ||
@@ -5,0 +5,0 @@ "main": "ip6.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39484
688