fix: prevent asset conflicts between React and Grid.js versions

Add coexistence checks to all enqueue methods to prevent loading
both React and Grid.js assets simultaneously.

Changes:
- ReactAdmin.php: Only enqueue React assets when ?react=1
- Init.php: Skip Grid.js when React active on admin pages
- Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0
- Customer.php, Product.php, License.php: Add coexistence checks

Now the toggle between Classic and React versions works correctly.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
dwindown
2026-04-18 17:02:14 +07:00
parent bd9cdac02e
commit e8fbfb14c1
74973 changed files with 6658406 additions and 71 deletions

66
node_modules/netmask/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,66 @@
## v2.0.2 (Apr 2, 2021)
### Bugfixes
* Fix `08` parsed as decimal while `018` rejected. ([commit](https://github.com/rs/node-netmask/commit/50a0053bd869b72313cc96ab73108bb83079c3f5))
## v2.0.1 (Mar 29, 2021)
### IMPORTANT: Security Fix
> This version contains an important security fix. If you are using netmask `<=2.0.0`, please upgrade to `2.0.1` or above.
* Rewrite byte parsing without using JS `parseInt()`([commit](https://github.com/rs/node-netmask/commit/3f19a056c4eb808ea4a29f234274c67bc5a848f4))
* This is [CVE-2021-29418](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-29418).
### Bugfixes
* Add checks on spaces before and after bytes
* This will now throw an exception when spaces are present like ' 1.2.3.4' or '1. 2.3.4' or '1.2.3.4 '.
### Internal Changes
* Avoid some useless memory allocations
* New Mocha testing suite, thanks @kaoudis [#36](https://github.com/rs/node-netmask/pull/36)
## v2.0.0 (Mar 19, 2021)
### Breaking Change
Previous API was treating IPs with less than four bytes as IP with a
netmask of the size of the provided bytes (1=8, 2=16, 3=24) and was
interpreting the IP as if it was completed with 0s on the right side.
*Proper IP parsing for these is to consider missing bytes as being 0s on
the left side.*
Mask size is no longer infered by the number of bytes provided.
This means that the input `216.240` will no longer be interpreted as `216.240.0.0/16`, but as `0.0.216.240/32`,
as per convention.
See [the change](https://github.com/rs/node-netmask/commit/9f9fc38c6db1a682d23289b5c9dc2009d957a00b).
### Bugfixes
* Fix improper parsing of hex bytes
## v1.1.0 (Mar 18, 2021)
### IMPORTANT: Security Fix
> This version contains an important security fix. If you are using netmask `<=1.0.6`, please upgrade to `1.1.0` or above.
* Fix improper parsing of octal bytes ([commit](https://github.com/rs/node-netmask/commit/4678fd840ad0b4730dbad2d415712c0782e886cc))
* This is [CVE-2021-28918](https://sick.codes/sick-2021-011).
* See also the [npm advisory](https://www.npmjs.com/advisories/1658)
### Other Changes
* Performance: Avoid large allocations when provided large netmasks (like `/8`)
* Thanks @dschenkelman [#34](https://github.com/rs/node-netmask/pull/34)
## v1.0.6 (May 30, 2016)
* Changes before this release are not documented here. Please see [the commit list](https://github.com/rs/node-netmask/commits/master)
or the [compare view](https://github.com/rs/node-netmask/compare/1.0.5...rs:1.0.6).

21
node_modules/netmask/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2011 Olivier Poitrey rs@rhapsodyk.net
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

112
node_modules/netmask/README.md generated vendored Normal file
View File

@@ -0,0 +1,112 @@
Netmask
=======
The Netmask class parses and understands IPv4 and IPv6 CIDR blocks so they can be explored and compared. This module is highly inspired by Perl [Net::Netmask](http://search.cpan.org/dist/Net-Netmask/) module.
Synopsis
--------
### IPv4
```js
var Netmask = require('netmask').Netmask
var block = new Netmask('10.0.0.0/12');
block.base; // 10.0.0.0
block.mask; // 255.240.0.0
block.bitmask; // 12
block.hostmask; // 0.15.255.255
block.broadcast; // 10.15.255.255
block.size; // 1048576
block.first; // 10.0.0.1
block.last; // 10.15.255.254
block.contains('10.0.8.10'); // true
block.contains('10.8.0.10'); // true
block.contains('192.168.1.20'); // false
block.next() // Netmask('10.16.0.0/12')
```
### IPv6
```js
var Netmask = require('netmask').Netmask
var block = new Netmask('2001:db8::/32');
block.base; // 2001:db8::
block.bitmask; // 32
block.first; // 2001:db8::
block.last; // 2001:db8:ffff:ffff:ffff:ffff:ffff:ffff
block.contains('2001:db8::1'); // true
block.contains('2001:db9::1'); // false
block.next() // Netmask('2001:db9::/32')
```
Constructing
------------
Netmask objects are created with an IP address and optionally a mask. The IP version is detected automatically. There are many forms that are recognized:
### IPv4
```
'216.240.32.0/24' // The preferred form.
'216.240.32.0/255.255.255.0'
'216.240.32.0', '255.255.255.0'
'216.240.32.0', 0xffffff00
'216.240.32.4' // A /32 block.
'0330.0360.040.04' // Octal form
'0xd8.0xf0.0x20.0x4' // Hex form
```
### IPv6
```
'2001:db8::/32' // The preferred form.
'2001:db8::', 32
'::1' // A /128 block.
'::ffff:192.168.1.1/120' // Mixed IPv4-mapped form.
'fe80::1%eth0' // Zone IDs are stripped.
```
API
---
- `.base`: The base address of the network block as a string (eg: 216.240.32.0 or 2001:db8::). Base does not give an indication of the size of the network block.
- `.mask`: The netmask as a string (eg: 255.255.255.0 or ffff:ffff::).
- `.hostmask`: The host mask which is the opposite of the netmask (eg: 0.0.0.255).
- `.bitmask`: The netmask as a number of bits in the network portion of the address for this block (eg: 24).
- `.size`: The number of IP addresses in a block (eg: 256).
- `.maskLong`: **Deprecated.** The netmask as an unsigned 32-bit integer. Only meaningful for IPv4; returns `0` for IPv6.
- `.netLong`: **Deprecated.** The base address as an unsigned 32-bit integer. Only meaningful for IPv4; returns `0` for IPv6.
- `.broadcast`: The blocks broadcast address (eg: 192.168.1.0/24 => 192.168.1.255). Always `undefined` for IPv6.
- `.first`, `.last`: First and last useable address.
- `.contains(ip or block)`: Returns a true if the IP number `ip` is part of the network. That is, a true value is returned if `ip` is between `base` and `broadcast`. If a Netmask object or a block is given, it returns true only of the given block fits inside the network.
- `.next(count)`: Without a `count`, return the next block of the same size after the current one. With a count, return the Nth block after the current one. A count of -1 returns the previous block. Undef will be returned if out of legal address space.
- `.toString()`: The netmask in base/bitmask format (e.g., '216.240.32.0/24')
Installation
------------
$ npm install netmask
Run all tests
-------------
$ npm test
License
-------
(The MIT License)
Copyright (c) 2011 Olivier Poitrey <rs@rhapsodyk.net>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

21
node_modules/netmask/dist/netmask.d.ts generated vendored Normal file
View File

@@ -0,0 +1,21 @@
import { ip2long, long2ip } from './netmask4';
declare class Netmask {
base: string;
mask: string;
hostmask: string;
bitmask: number;
maskLong: number;
netLong: number;
size: number;
first: string;
last: string;
broadcast: string | undefined;
private _impl;
constructor(net: string, mask?: string | number);
contains(ip: string | Netmask): boolean;
next(count?: number): Netmask;
/** @deprecated */
forEach(fn: (ip: string, long: number, index: number) => void): void;
toString(): string;
}
export { Netmask, ip2long, long2ip };

68
node_modules/netmask/dist/netmask.js generated vendored Normal file
View File

@@ -0,0 +1,68 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.long2ip = exports.ip2long = exports.Netmask = void 0;
const netmask4_1 = require("./netmask4");
Object.defineProperty(exports, "ip2long", { enumerable: true, get: function () { return netmask4_1.ip2long; } });
Object.defineProperty(exports, "long2ip", { enumerable: true, get: function () { return netmask4_1.long2ip; } });
const netmask6_1 = require("./netmask6");
class Netmask {
constructor(net, mask) {
if (typeof net !== 'string') {
throw new Error("Missing `net' parameter");
}
// Detect IPv6: check the address part (before any /) for ':'
const addrPart = net.indexOf('/') !== -1 ? net.substring(0, net.indexOf('/')) : net;
if (addrPart.indexOf(':') !== -1) {
this._impl = new netmask6_1.Netmask6Impl(net, mask);
}
else {
this._impl = new netmask4_1.Netmask4Impl(net, mask);
}
this.base = this._impl.base;
this.mask = this._impl.mask;
this.hostmask = this._impl.hostmask;
this.bitmask = this._impl.bitmask;
this.size = this._impl.size;
this.first = this._impl.first;
this.last = this._impl.last;
this.broadcast = this._impl.broadcast;
if (this._impl instanceof netmask4_1.Netmask4Impl) {
this.maskLong = this._impl.maskLong;
this.netLong = this._impl.netLong;
}
else {
this.maskLong = 0;
this.netLong = 0;
}
}
contains(ip) {
if (typeof ip === 'string') {
// If it has a '/', it's a CIDR block — wrap it
if (ip.indexOf('/') > 0) {
ip = new Netmask(ip);
}
// IPv4 shorthand (fewer than 4 octets, no colons) — wrap it
else if (ip.indexOf(':') === -1 && ip.split('.').length !== 4) {
ip = new Netmask(ip);
}
}
if (ip instanceof Netmask) {
return this.contains(ip.base) && this.contains(ip.broadcast || ip.last);
}
// Plain IP string — delegate to impl
return this._impl.contains(ip);
}
next(count = 1) {
const nextImpl = this._impl.next(count);
const result = new Netmask(nextImpl.base, nextImpl.bitmask);
return result;
}
/** @deprecated */
forEach(fn) {
this._impl.forEach(fn);
}
toString() {
return this._impl.toString();
}
}
exports.Netmask = Netmask;

20
node_modules/netmask/dist/netmask4.d.ts generated vendored Normal file
View File

@@ -0,0 +1,20 @@
declare function long2ip(long: number): string;
declare function ip2long(ip: string): number;
declare class Netmask4Impl {
maskLong: number;
bitmask: number;
netLong: number;
size: number;
base: string;
mask: string;
hostmask: string;
first: string;
last: string;
broadcast: string | undefined;
constructor(net: string, mask?: string | number);
contains(ip: string | Netmask4Impl): boolean;
next(count?: number): Netmask4Impl;
forEach(fn: (ip: string, long: number, index: number) => void): void;
toString(): string;
}
export { ip2long, long2ip, Netmask4Impl };

189
node_modules/netmask/dist/netmask4.js generated vendored Normal file
View File

@@ -0,0 +1,189 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Netmask4Impl = void 0;
exports.ip2long = ip2long;
exports.long2ip = long2ip;
function long2ip(long) {
const a = (long & (0xff << 24)) >>> 24;
const b = (long & (0xff << 16)) >>> 16;
const c = (long & (0xff << 8)) >>> 8;
const d = long & 0xff;
return [a, b, c, d].join('.');
}
const chr0 = '0'.charCodeAt(0);
const chra = 'a'.charCodeAt(0);
const chrA = 'A'.charCodeAt(0);
function parseNum(s) {
let n = 0;
let base = 10;
let dmax = '9';
let i = 0;
if (s.length > 1 && s[i] === '0') {
if (s[i + 1] === 'x' || s[i + 1] === 'X') {
i += 2;
base = 16;
}
else if ('0' <= s[i + 1] && s[i + 1] <= '9') {
i++;
base = 8;
dmax = '7';
}
}
const start = i;
while (i < s.length) {
if ('0' <= s[i] && s[i] <= dmax) {
n = (n * base + (s.charCodeAt(i) - chr0)) >>> 0;
}
else if (base === 16) {
if ('a' <= s[i] && s[i] <= 'f') {
n = (n * base + (10 + s.charCodeAt(i) - chra)) >>> 0;
}
else if ('A' <= s[i] && s[i] <= 'F') {
n = (n * base + (10 + s.charCodeAt(i) - chrA)) >>> 0;
}
else {
break;
}
}
else {
break;
}
if (n > 0xFFFFFFFF) {
throw new Error('too large');
}
i++;
}
if (i === start) {
throw new Error('empty octet');
}
return [n, i];
}
function ip2long(ip) {
const b = [];
for (let i = 0; i <= 3; i++) {
if (ip.length === 0) {
break;
}
if (i > 0) {
if (ip[0] !== '.') {
throw new Error('Invalid IP');
}
ip = ip.substring(1);
}
const [n, c] = parseNum(ip);
ip = ip.substring(c);
b.push(n);
}
if (ip.length !== 0) {
throw new Error('Invalid IP');
}
switch (b.length) {
case 1:
if (b[0] > 0xFFFFFFFF) {
throw new Error('Invalid IP');
}
return b[0] >>> 0;
case 2:
if (b[0] > 0xFF || b[1] > 0xFFFFFF) {
throw new Error('Invalid IP');
}
return (b[0] << 24 | b[1]) >>> 0;
case 3:
if (b[0] > 0xFF || b[1] > 0xFF || b[2] > 0xFFFF) {
throw new Error('Invalid IP');
}
return (b[0] << 24 | b[1] << 16 | b[2]) >>> 0;
case 4:
if (b[0] > 0xFF || b[1] > 0xFF || b[2] > 0xFF || b[3] > 0xFF) {
throw new Error('Invalid IP');
}
return (b[0] << 24 | b[1] << 16 | b[2] << 8 | b[3]) >>> 0;
default:
throw new Error('Invalid IP');
}
}
class Netmask4Impl {
constructor(net, mask) {
if (typeof net !== 'string') {
throw new Error("Missing `net' parameter");
}
let maskStr = mask;
if (!maskStr) {
const parts = net.split('/', 2);
net = parts[0];
maskStr = parts[1];
}
if (!maskStr) {
maskStr = 32;
}
if (typeof maskStr === 'string' && maskStr.indexOf('.') > -1) {
try {
this.maskLong = ip2long(maskStr);
}
catch (error) {
throw new Error("Invalid mask: " + maskStr);
}
this.bitmask = NaN;
for (let i = 32; i >= 0; i--) {
if (this.maskLong === (0xffffffff << (32 - i)) >>> 0) {
this.bitmask = i;
break;
}
}
}
else if (maskStr || maskStr === 0) {
this.bitmask = parseInt(maskStr, 10);
this.maskLong = 0;
if (this.bitmask > 0) {
this.maskLong = (0xffffffff << (32 - this.bitmask)) >>> 0;
}
}
else {
throw new Error("Invalid mask: empty");
}
try {
this.netLong = (ip2long(net) & this.maskLong) >>> 0;
}
catch (error) {
throw new Error("Invalid net address: " + net);
}
if (!(this.bitmask <= 32)) {
throw new Error("Invalid mask for ip4: " + maskStr);
}
this.size = Math.pow(2, 32 - this.bitmask);
this.base = long2ip(this.netLong);
this.mask = long2ip(this.maskLong);
this.hostmask = long2ip(~this.maskLong);
this.first = this.bitmask <= 30 ? long2ip(this.netLong + 1) : this.base;
this.last = this.bitmask <= 30 ? long2ip(this.netLong + this.size - 2) : long2ip(this.netLong + this.size - 1);
this.broadcast = this.bitmask <= 30 ? long2ip(this.netLong + this.size - 1) : undefined;
}
contains(ip) {
if (typeof ip === 'string' && (ip.indexOf('/') > 0 || ip.split('.').length !== 4)) {
ip = new Netmask4Impl(ip);
}
if (ip instanceof Netmask4Impl) {
return this.contains(ip.base) && this.contains((ip.broadcast || ip.last));
}
else {
return (ip2long(ip) & this.maskLong) >>> 0 === (this.netLong & this.maskLong) >>> 0;
}
}
next(count = 1) {
return new Netmask4Impl(long2ip(this.netLong + (this.size * count)), this.mask);
}
forEach(fn) {
let long = ip2long(this.first);
const lastLong = ip2long(this.last);
let index = 0;
while (long <= lastLong) {
fn(long2ip(long), long, index);
index++;
long++;
}
}
toString() {
return this.base + "/" + this.bitmask;
}
}
exports.Netmask4Impl = Netmask4Impl;

20
node_modules/netmask/dist/netmask6.d.ts generated vendored Normal file
View File

@@ -0,0 +1,20 @@
declare function ip6bigint(ip: string): bigint;
declare function bigint2ip6(n: bigint): string;
declare class Netmask6Impl {
netBigint: bigint;
maskBigint: bigint;
bitmask: number;
size: number;
base: string;
mask: string;
hostmask: string;
first: string;
last: string;
broadcast: undefined;
constructor(net: string, mask?: number);
contains(ip: string | Netmask6Impl): boolean;
next(count?: number): Netmask6Impl;
forEach(fn: (ip: string, long: number, index: number) => void): void;
toString(): string;
}
export { ip6bigint, bigint2ip6, Netmask6Impl };

187
node_modules/netmask/dist/netmask6.js generated vendored Normal file
View File

@@ -0,0 +1,187 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Netmask6Impl = void 0;
exports.ip6bigint = ip6bigint;
exports.bigint2ip6 = bigint2ip6;
const netmask4_1 = require("./netmask4");
const MAX_IPV6 = (1n << 128n) - 1n;
function ip6bigint(ip) {
// Strip zone ID (e.g. %eth0)
const zoneIdx = ip.indexOf('%');
if (zoneIdx !== -1) {
ip = ip.substring(0, zoneIdx);
}
// Handle mixed IPv4-mapped (e.g. ::ffff:192.168.1.1)
const lastColon = ip.lastIndexOf(':');
if (lastColon !== -1 && ip.indexOf('.', lastColon) !== -1) {
const ipv4Part = ip.substring(lastColon + 1);
const ipv4Long = (0, netmask4_1.ip2long)(ipv4Part);
// IPv4 part replaces last 2 groups (32 bits), expand prefix to 6 groups
const ipv6Prefix = ip.substring(0, lastColon + 1) + '0:0';
const prefixVal = parseIPv6Pure(ipv6Prefix);
return (prefixVal & ~0xffffffffn) | BigInt(ipv4Long);
}
return parseIPv6Pure(ip);
}
function parseIPv6Pure(ip) {
const doubleColonIdx = ip.indexOf('::');
let groups;
if (doubleColonIdx !== -1) {
const left = ip.substring(0, doubleColonIdx);
const right = ip.substring(doubleColonIdx + 2);
const leftGroups = left === '' ? [] : left.split(':');
const rightGroups = right === '' ? [] : right.split(':');
const missing = 8 - leftGroups.length - rightGroups.length;
if (missing < 0) {
throw new Error('Invalid IPv6: too many groups');
}
groups = [...leftGroups, ...Array(missing).fill('0'), ...rightGroups];
}
else {
groups = ip.split(':');
}
if (groups.length !== 8) {
throw new Error('Invalid IPv6: expected 8 groups, got ' + groups.length);
}
let result = 0n;
for (let i = 0; i < 8; i++) {
const g = groups[i];
if (g.length === 0 || g.length > 4) {
throw new Error('Invalid IPv6: bad group "' + g + '"');
}
const val = parseInt(g, 16);
if (isNaN(val) || val < 0 || val > 0xffff) {
throw new Error('Invalid IPv6: bad group "' + g + '"');
}
result = (result << 16n) | BigInt(val);
}
return result;
}
function bigint2ip6(n) {
if (n < 0n || n > MAX_IPV6) {
throw new Error('Invalid IPv6 address value');
}
const groups = [];
for (let i = 0; i < 8; i++) {
groups.unshift(Number(n & 0xffffn));
n >>= 16n;
}
// RFC 5952: find longest run of consecutive zero groups
let bestStart = -1;
let bestLen = 0;
let curStart = -1;
let curLen = 0;
for (let i = 0; i < 8; i++) {
if (groups[i] === 0) {
if (curStart === -1) {
curStart = i;
curLen = 1;
}
else {
curLen++;
}
}
else {
if (curLen > bestLen && curLen >= 2) {
bestStart = curStart;
bestLen = curLen;
}
curStart = -1;
curLen = 0;
}
}
if (curLen > bestLen && curLen >= 2) {
bestStart = curStart;
bestLen = curLen;
}
if (bestStart !== -1 && bestStart + bestLen === 8 && bestStart > 0) {
const before = groups.slice(0, bestStart).map(g => g.toString(16));
return before.join(':') + '::';
}
else if (bestStart === 0) {
const after = groups.slice(bestLen).map(g => g.toString(16));
return '::' + after.join(':');
}
else if (bestStart > 0) {
const before = groups.slice(0, bestStart).map(g => g.toString(16));
const after = groups.slice(bestStart + bestLen).map(g => g.toString(16));
return before.join(':') + '::' + after.join(':');
}
else {
return groups.map(g => g.toString(16)).join(':');
}
}
class Netmask6Impl {
constructor(net, mask) {
if (typeof net !== 'string') {
throw new Error("Missing `net' parameter");
}
let prefixLen = mask;
if (prefixLen === undefined || prefixLen === null) {
const slashIdx = net.indexOf('/');
if (slashIdx !== -1) {
prefixLen = parseInt(net.substring(slashIdx + 1), 10);
net = net.substring(0, slashIdx);
}
else {
prefixLen = 128;
}
}
if (isNaN(prefixLen) || prefixLen < 0 || prefixLen > 128) {
throw new Error('Invalid mask for IPv6: ' + prefixLen);
}
this.bitmask = prefixLen;
if (this.bitmask === 0) {
this.maskBigint = 0n;
}
else {
this.maskBigint = (MAX_IPV6 >> BigInt(128 - this.bitmask)) << BigInt(128 - this.bitmask);
}
try {
this.netBigint = ip6bigint(net) & this.maskBigint;
}
catch (error) {
throw new Error('Invalid IPv6 net address: ' + net);
}
this.size = Number(1n << BigInt(128 - this.bitmask));
this.base = bigint2ip6(this.netBigint);
this.mask = bigint2ip6(this.maskBigint);
this.hostmask = bigint2ip6(~this.maskBigint & MAX_IPV6);
this.first = this.base;
this.last = bigint2ip6(this.netBigint + (1n << BigInt(128 - this.bitmask)) - 1n);
this.broadcast = undefined;
}
contains(ip) {
if (typeof ip === 'string') {
if (ip.indexOf('/') > 0) {
ip = new Netmask6Impl(ip);
}
}
if (ip instanceof Netmask6Impl) {
return this.contains(ip.base) && this.contains(ip.last);
}
else {
const addr = ip6bigint(ip);
return (addr & this.maskBigint) === this.netBigint;
}
}
next(count = 1) {
const sizeBig = 1n << BigInt(128 - this.bitmask);
return new Netmask6Impl(bigint2ip6(this.netBigint + sizeBig * BigInt(count)), this.bitmask);
}
forEach(fn) {
let addr = this.netBigint;
const sizeBig = 1n << BigInt(128 - this.bitmask);
const lastAddr = this.netBigint + sizeBig - 1n;
let index = 0;
while (addr <= lastAddr) {
fn(bigint2ip6(addr), Number(addr), index);
index++;
addr++;
}
}
toString() {
return this.base + '/' + this.bitmask;
}
}
exports.Netmask6Impl = Netmask6Impl;

45
node_modules/netmask/package.json generated vendored Normal file
View File

@@ -0,0 +1,45 @@
{
"author": "Olivier Poitrey <rs@rhapsodyk.net>",
"name": "netmask",
"description": "Parse and lookup IP network blocks",
"version": "2.1.1",
"homepage": "https://github.com/rs/node-netmask",
"bugs": "https://github.com/rs/node-netmask/issues",
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/rs/node-netmask.git"
},
"keywords": [
"net",
"mask",
"ip",
"network",
"cidr",
"netmask",
"subnet",
"ipcalc"
],
"files": [
"dist",
"README.md",
"CHANGELOG.md",
"LICENSE"
],
"main": "./dist/netmask",
"types": "./dist/netmask.d.ts",
"scripts": {
"prepublish": "tsc",
"test": "tsc && mocha --require ts-node/register tests/*.ts"
},
"engines": {
"node": ">= 0.4.0"
},
"devDependencies": {
"@types/mocha": "^9.0.0",
"@types/node": "^18.0.0",
"mocha": "^10.2.0",
"ts-node": "^10.0.0",
"typescript": "^5.0.0"
}
}