Deployed the page to Github Pages.

This commit is contained in:
Batuhan Berk Başoğlu 2024-11-03 21:30:09 -05:00
parent 1d79754e93
commit 2c89899458
Signed by: batuhan-basoglu
SSH key fingerprint: SHA256:kEsnuHX+qbwhxSAXPUQ4ox535wFHu/hIRaa53FzxRpo
62797 changed files with 6551425 additions and 15279 deletions

5
node_modules/ip-address/dist/address-error.d.ts generated vendored Normal file
View file

@ -0,0 +1,5 @@
export declare class AddressError extends Error {
parseMessage?: string;
constructor(message: string, parseMessage?: string);
}
//# sourceMappingURL=address-error.d.ts.map

1
node_modules/ip-address/dist/address-error.d.ts.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"address-error.d.ts","sourceRoot":"","sources":["../src/address-error.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;gBAEV,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM;CASnD"}

14
node_modules/ip-address/dist/address-error.js generated vendored Normal file
View file

@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AddressError = void 0;
class AddressError extends Error {
constructor(message, parseMessage) {
super(message);
this.name = 'AddressError';
if (parseMessage !== null) {
this.parseMessage = parseMessage;
}
}
}
exports.AddressError = AddressError;
//# sourceMappingURL=address-error.js.map

1
node_modules/ip-address/dist/address-error.js.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"address-error.js","sourceRoot":"","sources":["../src/address-error.ts"],"names":[],"mappings":";;;AAAA,MAAa,YAAa,SAAQ,KAAK;IAGrC,YAAY,OAAe,EAAE,YAAqB;QAChD,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAE3B,IAAI,YAAY,KAAK,IAAI,EAAE;YACzB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;SAClC;IACH,CAAC;CACF;AAZD,oCAYC"}

8
node_modules/ip-address/dist/common.d.ts generated vendored Normal file
View file

@ -0,0 +1,8 @@
import { Address4 } from './ipv4';
import { Address6 } from './ipv6';
export interface ReverseFormOptions {
omitSuffix?: boolean;
}
export declare function isInSubnet(this: Address4 | Address6, address: Address4 | Address6): boolean;
export declare function isCorrect(defaultBits: number): (this: Address4 | Address6) => boolean;
//# sourceMappingURL=common.d.ts.map

1
node_modules/ip-address/dist/common.d.ts.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,MAAM,WAAW,kBAAkB;IACjC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,EAAE,OAAO,EAAE,QAAQ,GAAG,QAAQ,WAUjF;AAED,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,UACpB,QAAQ,GAAG,QAAQ,aAW3C"}

26
node_modules/ip-address/dist/common.js generated vendored Normal file
View file

@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isCorrect = exports.isInSubnet = void 0;
function isInSubnet(address) {
if (this.subnetMask < address.subnetMask) {
return false;
}
if (this.mask(address.subnetMask) === address.mask()) {
return true;
}
return false;
}
exports.isInSubnet = isInSubnet;
function isCorrect(defaultBits) {
return function () {
if (this.addressMinusSuffix !== this.correctForm()) {
return false;
}
if (this.subnetMask === defaultBits && !this.parsedSubnet) {
return true;
}
return this.parsedSubnet === String(this.subnetMask);
};
}
exports.isCorrect = isCorrect;
//# sourceMappingURL=common.js.map

1
node_modules/ip-address/dist/common.js.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":";;;AAOA,SAAgB,UAAU,CAA4B,OAA4B;IAChF,IAAI,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,EAAE;QACxC,OAAO,KAAK,CAAC;KACd;IAED,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,OAAO,CAAC,IAAI,EAAE,EAAE;QACpD,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAVD,gCAUC;AAED,SAAgB,SAAS,CAAC,WAAmB;IAC3C,OAAO;QACL,IAAI,IAAI,CAAC,kBAAkB,KAAK,IAAI,CAAC,WAAW,EAAE,EAAE;YAClD,OAAO,KAAK,CAAC;SACd;QAED,IAAI,IAAI,CAAC,UAAU,KAAK,WAAW,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YACzD,OAAO,IAAI,CAAC;SACb;QAED,OAAO,IAAI,CAAC,YAAY,KAAK,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACvD,CAAC,CAAC;AACJ,CAAC;AAZD,8BAYC"}

11
node_modules/ip-address/dist/ip-address.d.ts generated vendored Normal file
View file

@ -0,0 +1,11 @@
import { Address4 } from './ipv4';
import { Address6 } from './ipv6';
import { AddressError } from './address-error';
export { Address4 };
export { Address6 };
export { AddressError };
import * as helpers from './v6/helpers';
export declare const v6: {
helpers: typeof helpers;
};
//# sourceMappingURL=ip-address.d.ts.map

1
node_modules/ip-address/dist/ip-address.d.ts.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"ip-address.d.ts","sourceRoot":"","sources":["../src/ip-address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC,eAAO,MAAM,EAAE;;CAAc,CAAC"}

35
node_modules/ip-address/dist/ip-address.js generated vendored Normal file
View file

@ -0,0 +1,35 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.v6 = exports.AddressError = exports.Address6 = exports.Address4 = void 0;
const ipv4_1 = require("./ipv4");
Object.defineProperty(exports, "Address4", { enumerable: true, get: function () { return ipv4_1.Address4; } });
const ipv6_1 = require("./ipv6");
Object.defineProperty(exports, "Address6", { enumerable: true, get: function () { return ipv6_1.Address6; } });
const address_error_1 = require("./address-error");
Object.defineProperty(exports, "AddressError", { enumerable: true, get: function () { return address_error_1.AddressError; } });
const helpers = __importStar(require("./v6/helpers"));
exports.v6 = { helpers };
//# sourceMappingURL=ip-address.js.map

1
node_modules/ip-address/dist/ip-address.js.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"ip-address.js","sourceRoot":"","sources":["../src/ip-address.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAkC;AAIzB,yFAJA,eAAQ,OAIA;AAHjB,iCAAkC;AAIzB,yFAJA,eAAQ,OAIA;AAHjB,mDAA+C;AAItC,6FAJA,4BAAY,OAIA;AAErB,sDAAwC;AAE3B,QAAA,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC"}

194
node_modules/ip-address/dist/ipv4.d.ts generated vendored Normal file
View file

@ -0,0 +1,194 @@
import * as common from './common';
import { BigInteger } from 'jsbn';
/**
* Represents an IPv4 address
* @class Address4
* @param {string} address - An IPv4 address string
*/
export declare class Address4 {
address: string;
addressMinusSuffix?: string;
groups: number;
parsedAddress: string[];
parsedSubnet: string;
subnet: string;
subnetMask: number;
v4: boolean;
constructor(address: string);
static isValid(address: string): boolean;
parse(address: string): string[];
/**
* Returns the correct form of an address
* @memberof Address4
* @instance
* @returns {String}
*/
correctForm(): string;
/**
* Returns true if the address is correct, false otherwise
* @memberof Address4
* @instance
* @returns {Boolean}
*/
isCorrect: (this: Address4 | import("./ipv6").Address6) => boolean;
/**
* Converts a hex string to an IPv4 address object
* @memberof Address4
* @static
* @param {string} hex - a hex string to convert
* @returns {Address4}
*/
static fromHex(hex: string): Address4;
/**
* Converts an integer into a IPv4 address object
* @memberof Address4
* @static
* @param {integer} integer - a number to convert
* @returns {Address4}
*/
static fromInteger(integer: number): Address4;
/**
* Return an address from in-addr.arpa form
* @memberof Address4
* @static
* @param {string} arpaFormAddress - an 'in-addr.arpa' form ipv4 address
* @returns {Adress4}
* @example
* var address = Address4.fromArpa(42.2.0.192.in-addr.arpa.)
* address.correctForm(); // '192.0.2.42'
*/
static fromArpa(arpaFormAddress: string): Address4;
/**
* Converts an IPv4 address object to a hex string
* @memberof Address4
* @instance
* @returns {String}
*/
toHex(): string;
/**
* Converts an IPv4 address object to an array of bytes
* @memberof Address4
* @instance
* @returns {Array}
*/
toArray(): number[];
/**
* Converts an IPv4 address object to an IPv6 address group
* @memberof Address4
* @instance
* @returns {String}
*/
toGroup6(): string;
/**
* Returns the address as a BigInteger
* @memberof Address4
* @instance
* @returns {BigInteger}
*/
bigInteger(): BigInteger;
/**
* Helper function getting start address.
* @memberof Address4
* @instance
* @returns {BigInteger}
*/
_startAddress(): BigInteger;
/**
* The first address in the range given by this address' subnet.
* Often referred to as the Network Address.
* @memberof Address4
* @instance
* @returns {Address4}
*/
startAddress(): Address4;
/**
* The first host address in the range given by this address's subnet ie
* the first address after the Network Address
* @memberof Address4
* @instance
* @returns {Address4}
*/
startAddressExclusive(): Address4;
/**
* Helper function getting end address.
* @memberof Address4
* @instance
* @returns {BigInteger}
*/
_endAddress(): BigInteger;
/**
* The last address in the range given by this address' subnet
* Often referred to as the Broadcast
* @memberof Address4
* @instance
* @returns {Address4}
*/
endAddress(): Address4;
/**
* The last host address in the range given by this address's subnet ie
* the last address prior to the Broadcast Address
* @memberof Address4
* @instance
* @returns {Address4}
*/
endAddressExclusive(): Address4;
/**
* Converts a BigInteger to a v4 address object
* @memberof Address4
* @static
* @param {BigInteger} bigInteger - a BigInteger to convert
* @returns {Address4}
*/
static fromBigInteger(bigInteger: BigInteger): Address4;
/**
* Returns the first n bits of the address, defaulting to the
* subnet mask
* @memberof Address4
* @instance
* @returns {String}
*/
mask(mask?: number): string;
/**
* Returns the bits in the given range as a base-2 string
* @memberof Address4
* @instance
* @returns {string}
*/
getBitsBase2(start: number, end: number): string;
/**
* Return the reversed ip6.arpa form of the address
* @memberof Address4
* @param {Object} options
* @param {boolean} options.omitSuffix - omit the "in-addr.arpa" suffix
* @instance
* @returns {String}
*/
reverseForm(options?: common.ReverseFormOptions): string;
/**
* Returns true if the given address is in the subnet of the current address
* @memberof Address4
* @instance
* @returns {boolean}
*/
isInSubnet: typeof common.isInSubnet;
/**
* Returns true if the given address is a multicast address
* @memberof Address4
* @instance
* @returns {boolean}
*/
isMulticast(): boolean;
/**
* Returns a zero-padded base-2 string representation of the address
* @memberof Address4
* @instance
* @returns {string}
*/
binaryZeroPad(): string;
/**
* Groups an IPv4 address for inclusion at the end of an IPv6 address
* @returns {String}
*/
groupForV6(): string;
}
//# sourceMappingURL=ipv4.d.ts.map

1
node_modules/ip-address/dist/ipv4.d.ts.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"ipv4.d.ts","sourceRoot":"","sources":["../src/ipv4.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAGnC,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGlC;;;;GAIG;AACH,qBAAa,QAAQ;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAoB;IAClC,aAAa,EAAE,MAAM,EAAE,CAAM;IAC7B,YAAY,EAAE,MAAM,CAAM;IAC1B,MAAM,EAAE,MAAM,CAAS;IACvB,UAAU,EAAE,MAAM,CAAM;IACxB,EAAE,EAAE,OAAO,CAAQ;gBAEP,OAAO,EAAE,MAAM;IAsB3B,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAcxC,KAAK,CAAC,OAAO,EAAE,MAAM;IAUrB;;;;;OAKG;IACH,WAAW,IAAI,MAAM;IAIrB;;;;;OAKG;IACH,SAAS,0DAAoC;IAE7C;;;;;;OAMG;IACH,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ;IAcrC;;;;;;OAMG;IACH,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ;IAI7C;;;;;;;;;OASG;IACH,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,QAAQ;IASlD;;;;;OAKG;IACH,KAAK,IAAI,MAAM;IAIf;;;;;OAKG;IACH,OAAO,IAAI,MAAM,EAAE;IAInB;;;;;OAKG;IACH,QAAQ,IAAI,MAAM;IAiBlB;;;;;OAKG;IACH,UAAU,IAAI,UAAU;IAOxB;;;;;OAKG;IACH,aAAa,IAAI,UAAU;IAI3B;;;;;;OAMG;IACH,YAAY,IAAI,QAAQ;IAIxB;;;;;;OAMG;IACH,qBAAqB,IAAI,QAAQ;IAKjC;;;;;OAKG;IACH,WAAW,IAAI,UAAU;IAIzB;;;;;;OAMG;IACH,UAAU,IAAI,QAAQ;IAItB;;;;;;OAMG;IACH,mBAAmB,IAAI,QAAQ;IAK/B;;;;;;OAMG;IACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,QAAQ;IAIvD;;;;;;OAMG;IACH,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM;IAQ3B;;;;;OAKG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAIhD;;;;;;;OAOG;IACH,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,kBAAkB,GAAG,MAAM;IAcxD;;;;;OAKG;IACH,UAAU,2BAAqB;IAE/B;;;;;OAKG;IACH,WAAW,IAAI,OAAO;IAItB;;;;;OAKG;IACH,aAAa,IAAI,MAAM;IAIvB;;;OAGG;IACH,UAAU,IAAI,MAAM;CAYrB"}

326
node_modules/ip-address/dist/ipv4.js generated vendored Normal file
View file

@ -0,0 +1,326 @@
"use strict";
/* eslint-disable no-param-reassign */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Address4 = void 0;
const common = __importStar(require("./common"));
const constants = __importStar(require("./v4/constants"));
const address_error_1 = require("./address-error");
const jsbn_1 = require("jsbn");
const sprintf_js_1 = require("sprintf-js");
/**
* Represents an IPv4 address
* @class Address4
* @param {string} address - An IPv4 address string
*/
class Address4 {
constructor(address) {
this.groups = constants.GROUPS;
this.parsedAddress = [];
this.parsedSubnet = '';
this.subnet = '/32';
this.subnetMask = 32;
this.v4 = true;
/**
* Returns true if the address is correct, false otherwise
* @memberof Address4
* @instance
* @returns {Boolean}
*/
this.isCorrect = common.isCorrect(constants.BITS);
/**
* Returns true if the given address is in the subnet of the current address
* @memberof Address4
* @instance
* @returns {boolean}
*/
this.isInSubnet = common.isInSubnet;
this.address = address;
const subnet = constants.RE_SUBNET_STRING.exec(address);
if (subnet) {
this.parsedSubnet = subnet[0].replace('/', '');
this.subnetMask = parseInt(this.parsedSubnet, 10);
this.subnet = `/${this.subnetMask}`;
if (this.subnetMask < 0 || this.subnetMask > constants.BITS) {
throw new address_error_1.AddressError('Invalid subnet mask.');
}
address = address.replace(constants.RE_SUBNET_STRING, '');
}
this.addressMinusSuffix = address;
this.parsedAddress = this.parse(address);
}
static isValid(address) {
try {
// eslint-disable-next-line no-new
new Address4(address);
return true;
}
catch (e) {
return false;
}
}
/*
* Parses a v4 address
*/
parse(address) {
const groups = address.split('.');
if (!address.match(constants.RE_ADDRESS)) {
throw new address_error_1.AddressError('Invalid IPv4 address.');
}
return groups;
}
/**
* Returns the correct form of an address
* @memberof Address4
* @instance
* @returns {String}
*/
correctForm() {
return this.parsedAddress.map((part) => parseInt(part, 10)).join('.');
}
/**
* Converts a hex string to an IPv4 address object
* @memberof Address4
* @static
* @param {string} hex - a hex string to convert
* @returns {Address4}
*/
static fromHex(hex) {
const padded = hex.replace(/:/g, '').padStart(8, '0');
const groups = [];
let i;
for (i = 0; i < 8; i += 2) {
const h = padded.slice(i, i + 2);
groups.push(parseInt(h, 16));
}
return new Address4(groups.join('.'));
}
/**
* Converts an integer into a IPv4 address object
* @memberof Address4
* @static
* @param {integer} integer - a number to convert
* @returns {Address4}
*/
static fromInteger(integer) {
return Address4.fromHex(integer.toString(16));
}
/**
* Return an address from in-addr.arpa form
* @memberof Address4
* @static
* @param {string} arpaFormAddress - an 'in-addr.arpa' form ipv4 address
* @returns {Adress4}
* @example
* var address = Address4.fromArpa(42.2.0.192.in-addr.arpa.)
* address.correctForm(); // '192.0.2.42'
*/
static fromArpa(arpaFormAddress) {
// remove ending ".in-addr.arpa." or just "."
const leader = arpaFormAddress.replace(/(\.in-addr\.arpa)?\.$/, '');
const address = leader.split('.').reverse().join('.');
return new Address4(address);
}
/**
* Converts an IPv4 address object to a hex string
* @memberof Address4
* @instance
* @returns {String}
*/
toHex() {
return this.parsedAddress.map((part) => (0, sprintf_js_1.sprintf)('%02x', parseInt(part, 10))).join(':');
}
/**
* Converts an IPv4 address object to an array of bytes
* @memberof Address4
* @instance
* @returns {Array}
*/
toArray() {
return this.parsedAddress.map((part) => parseInt(part, 10));
}
/**
* Converts an IPv4 address object to an IPv6 address group
* @memberof Address4
* @instance
* @returns {String}
*/
toGroup6() {
const output = [];
let i;
for (i = 0; i < constants.GROUPS; i += 2) {
const hex = (0, sprintf_js_1.sprintf)('%02x%02x', parseInt(this.parsedAddress[i], 10), parseInt(this.parsedAddress[i + 1], 10));
output.push((0, sprintf_js_1.sprintf)('%x', parseInt(hex, 16)));
}
return output.join(':');
}
/**
* Returns the address as a BigInteger
* @memberof Address4
* @instance
* @returns {BigInteger}
*/
bigInteger() {
return new jsbn_1.BigInteger(this.parsedAddress.map((n) => (0, sprintf_js_1.sprintf)('%02x', parseInt(n, 10))).join(''), 16);
}
/**
* Helper function getting start address.
* @memberof Address4
* @instance
* @returns {BigInteger}
*/
_startAddress() {
return new jsbn_1.BigInteger(this.mask() + '0'.repeat(constants.BITS - this.subnetMask), 2);
}
/**
* The first address in the range given by this address' subnet.
* Often referred to as the Network Address.
* @memberof Address4
* @instance
* @returns {Address4}
*/
startAddress() {
return Address4.fromBigInteger(this._startAddress());
}
/**
* The first host address in the range given by this address's subnet ie
* the first address after the Network Address
* @memberof Address4
* @instance
* @returns {Address4}
*/
startAddressExclusive() {
const adjust = new jsbn_1.BigInteger('1');
return Address4.fromBigInteger(this._startAddress().add(adjust));
}
/**
* Helper function getting end address.
* @memberof Address4
* @instance
* @returns {BigInteger}
*/
_endAddress() {
return new jsbn_1.BigInteger(this.mask() + '1'.repeat(constants.BITS - this.subnetMask), 2);
}
/**
* The last address in the range given by this address' subnet
* Often referred to as the Broadcast
* @memberof Address4
* @instance
* @returns {Address4}
*/
endAddress() {
return Address4.fromBigInteger(this._endAddress());
}
/**
* The last host address in the range given by this address's subnet ie
* the last address prior to the Broadcast Address
* @memberof Address4
* @instance
* @returns {Address4}
*/
endAddressExclusive() {
const adjust = new jsbn_1.BigInteger('1');
return Address4.fromBigInteger(this._endAddress().subtract(adjust));
}
/**
* Converts a BigInteger to a v4 address object
* @memberof Address4
* @static
* @param {BigInteger} bigInteger - a BigInteger to convert
* @returns {Address4}
*/
static fromBigInteger(bigInteger) {
return Address4.fromInteger(parseInt(bigInteger.toString(), 10));
}
/**
* Returns the first n bits of the address, defaulting to the
* subnet mask
* @memberof Address4
* @instance
* @returns {String}
*/
mask(mask) {
if (mask === undefined) {
mask = this.subnetMask;
}
return this.getBitsBase2(0, mask);
}
/**
* Returns the bits in the given range as a base-2 string
* @memberof Address4
* @instance
* @returns {string}
*/
getBitsBase2(start, end) {
return this.binaryZeroPad().slice(start, end);
}
/**
* Return the reversed ip6.arpa form of the address
* @memberof Address4
* @param {Object} options
* @param {boolean} options.omitSuffix - omit the "in-addr.arpa" suffix
* @instance
* @returns {String}
*/
reverseForm(options) {
if (!options) {
options = {};
}
const reversed = this.correctForm().split('.').reverse().join('.');
if (options.omitSuffix) {
return reversed;
}
return (0, sprintf_js_1.sprintf)('%s.in-addr.arpa.', reversed);
}
/**
* Returns true if the given address is a multicast address
* @memberof Address4
* @instance
* @returns {boolean}
*/
isMulticast() {
return this.isInSubnet(new Address4('224.0.0.0/4'));
}
/**
* Returns a zero-padded base-2 string representation of the address
* @memberof Address4
* @instance
* @returns {string}
*/
binaryZeroPad() {
return this.bigInteger().toString(2).padStart(constants.BITS, '0');
}
/**
* Groups an IPv4 address for inclusion at the end of an IPv6 address
* @returns {String}
*/
groupForV6() {
const segments = this.parsedAddress;
return this.address.replace(constants.RE_ADDRESS, (0, sprintf_js_1.sprintf)('<span class="hover-group group-v4 group-6">%s</span>.<span class="hover-group group-v4 group-7">%s</span>', segments.slice(0, 2).join('.'), segments.slice(2, 4).join('.')));
}
}
exports.Address4 = Address4;
//# sourceMappingURL=ipv4.js.map

1
node_modules/ip-address/dist/ipv4.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

429
node_modules/ip-address/dist/ipv6.d.ts generated vendored Normal file
View file

@ -0,0 +1,429 @@
import * as common from './common';
import { Address4 } from './ipv4';
import { BigInteger } from 'jsbn';
interface SixToFourProperties {
prefix: string;
gateway: string;
}
interface TeredoProperties {
prefix: string;
server4: string;
client4: string;
flags: string;
coneNat: boolean;
microsoft: {
reserved: boolean;
universalLocal: boolean;
groupIndividual: boolean;
nonce: string;
};
udpPort: string;
}
/**
* Represents an IPv6 address
* @class Address6
* @param {string} address - An IPv6 address string
* @param {number} [groups=8] - How many octets to parse
* @example
* var address = new Address6('2001::/32');
*/
export declare class Address6 {
address4?: Address4;
address: string;
addressMinusSuffix: string;
elidedGroups?: number;
elisionBegin?: number;
elisionEnd?: number;
groups: number;
parsedAddress4?: string;
parsedAddress: string[];
parsedSubnet: string;
subnet: string;
subnetMask: number;
v4: boolean;
zone: string;
constructor(address: string, optionalGroups?: number);
static isValid(address: string): boolean;
/**
* Convert a BigInteger to a v6 address object
* @memberof Address6
* @static
* @param {BigInteger} bigInteger - a BigInteger to convert
* @returns {Address6}
* @example
* var bigInteger = new BigInteger('1000000000000');
* var address = Address6.fromBigInteger(bigInteger);
* address.correctForm(); // '::e8:d4a5:1000'
*/
static fromBigInteger(bigInteger: BigInteger): Address6;
/**
* Convert a URL (with optional port number) to an address object
* @memberof Address6
* @static
* @param {string} url - a URL with optional port number
* @example
* var addressAndPort = Address6.fromURL('http://[ffff::]:8080/foo/');
* addressAndPort.address.correctForm(); // 'ffff::'
* addressAndPort.port; // 8080
*/
static fromURL(url: string): {
error: string;
address: null;
port: null;
} | {
address: Address6;
port: number | null;
error?: undefined;
};
/**
* Create an IPv6-mapped address given an IPv4 address
* @memberof Address6
* @static
* @param {string} address - An IPv4 address string
* @returns {Address6}
* @example
* var address = Address6.fromAddress4('192.168.0.1');
* address.correctForm(); // '::ffff:c0a8:1'
* address.to4in6(); // '::ffff:192.168.0.1'
*/
static fromAddress4(address: string): Address6;
/**
* Return an address from ip6.arpa form
* @memberof Address6
* @static
* @param {string} arpaFormAddress - an 'ip6.arpa' form address
* @returns {Adress6}
* @example
* var address = Address6.fromArpa(e.f.f.f.3.c.2.6.f.f.f.e.6.6.8.e.1.0.6.7.9.4.e.c.0.0.0.0.1.0.0.2.ip6.arpa.)
* address.correctForm(); // '2001:0:ce49:7601:e866:efff:62c3:fffe'
*/
static fromArpa(arpaFormAddress: string): Address6;
/**
* Return the Microsoft UNC transcription of the address
* @memberof Address6
* @instance
* @returns {String} the Microsoft UNC transcription of the address
*/
microsoftTranscription(): string;
/**
* Return the first n bits of the address, defaulting to the subnet mask
* @memberof Address6
* @instance
* @param {number} [mask=subnet] - the number of bits to mask
* @returns {String} the first n bits of the address as a string
*/
mask(mask?: number): string;
/**
* Return the number of possible subnets of a given size in the address
* @memberof Address6
* @instance
* @param {number} [size=128] - the subnet size
* @returns {String}
*/
possibleSubnets(subnetSize?: number): string;
/**
* Helper function getting start address.
* @memberof Address6
* @instance
* @returns {BigInteger}
*/
_startAddress(): BigInteger;
/**
* The first address in the range given by this address' subnet
* Often referred to as the Network Address.
* @memberof Address6
* @instance
* @returns {Address6}
*/
startAddress(): Address6;
/**
* The first host address in the range given by this address's subnet ie
* the first address after the Network Address
* @memberof Address6
* @instance
* @returns {Address6}
*/
startAddressExclusive(): Address6;
/**
* Helper function getting end address.
* @memberof Address6
* @instance
* @returns {BigInteger}
*/
_endAddress(): BigInteger;
/**
* The last address in the range given by this address' subnet
* Often referred to as the Broadcast
* @memberof Address6
* @instance
* @returns {Address6}
*/
endAddress(): Address6;
/**
* The last host address in the range given by this address's subnet ie
* the last address prior to the Broadcast Address
* @memberof Address6
* @instance
* @returns {Address6}
*/
endAddressExclusive(): Address6;
/**
* Return the scope of the address
* @memberof Address6
* @instance
* @returns {String}
*/
getScope(): string;
/**
* Return the type of the address
* @memberof Address6
* @instance
* @returns {String}
*/
getType(): string;
/**
* Return the bits in the given range as a BigInteger
* @memberof Address6
* @instance
* @returns {BigInteger}
*/
getBits(start: number, end: number): BigInteger;
/**
* Return the bits in the given range as a base-2 string
* @memberof Address6
* @instance
* @returns {String}
*/
getBitsBase2(start: number, end: number): string;
/**
* Return the bits in the given range as a base-16 string
* @memberof Address6
* @instance
* @returns {String}
*/
getBitsBase16(start: number, end: number): string;
/**
* Return the bits that are set past the subnet mask length
* @memberof Address6
* @instance
* @returns {String}
*/
getBitsPastSubnet(): string;
/**
* Return the reversed ip6.arpa form of the address
* @memberof Address6
* @param {Object} options
* @param {boolean} options.omitSuffix - omit the "ip6.arpa" suffix
* @instance
* @returns {String}
*/
reverseForm(options?: common.ReverseFormOptions): string;
/**
* Return the correct form of the address
* @memberof Address6
* @instance
* @returns {String}
*/
correctForm(): string;
/**
* Return a zero-padded base-2 string representation of the address
* @memberof Address6
* @instance
* @returns {String}
* @example
* var address = new Address6('2001:4860:4001:803::1011');
* address.binaryZeroPad();
* // '0010000000000001010010000110000001000000000000010000100000000011
* // 0000000000000000000000000000000000000000000000000001000000010001'
*/
binaryZeroPad(): string;
parse4in6(address: string): string;
parse(address: string): string[];
/**
* Return the canonical form of the address
* @memberof Address6
* @instance
* @returns {String}
*/
canonicalForm(): string;
/**
* Return the decimal form of the address
* @memberof Address6
* @instance
* @returns {String}
*/
decimal(): string;
/**
* Return the address as a BigInteger
* @memberof Address6
* @instance
* @returns {BigInteger}
*/
bigInteger(): BigInteger;
/**
* Return the last two groups of this address as an IPv4 address string
* @memberof Address6
* @instance
* @returns {Address4}
* @example
* var address = new Address6('2001:4860:4001::1825:bf11');
* address.to4().correctForm(); // '24.37.191.17'
*/
to4(): Address4;
/**
* Return the v4-in-v6 form of the address
* @memberof Address6
* @instance
* @returns {String}
*/
to4in6(): string;
/**
* Return an object containing the Teredo properties of the address
* @memberof Address6
* @instance
* @returns {Object}
*/
inspectTeredo(): TeredoProperties;
/**
* Return an object containing the 6to4 properties of the address
* @memberof Address6
* @instance
* @returns {Object}
*/
inspect6to4(): SixToFourProperties;
/**
* Return a v6 6to4 address from a v6 v4inv6 address
* @memberof Address6
* @instance
* @returns {Address6}
*/
to6to4(): Address6 | null;
/**
* Return a byte array
* @memberof Address6
* @instance
* @returns {Array}
*/
toByteArray(): number[];
/**
* Return an unsigned byte array
* @memberof Address6
* @instance
* @returns {Array}
*/
toUnsignedByteArray(): number[];
/**
* Convert a byte array to an Address6 object
* @memberof Address6
* @static
* @returns {Address6}
*/
static fromByteArray(bytes: Array<any>): Address6;
/**
* Convert an unsigned byte array to an Address6 object
* @memberof Address6
* @static
* @returns {Address6}
*/
static fromUnsignedByteArray(bytes: Array<any>): Address6;
/**
* Returns true if the given address is in the subnet of the current address
* @memberof Address6
* @instance
* @returns {boolean}
*/
isInSubnet: typeof common.isInSubnet;
/**
* Returns true if the address is correct, false otherwise
* @memberof Address6
* @instance
* @returns {boolean}
*/
isCorrect: (this: Address4 | Address6) => boolean;
/**
* Returns true if the address is in the canonical form, false otherwise
* @memberof Address6
* @instance
* @returns {boolean}
*/
isCanonical(): boolean;
/**
* Returns true if the address is a link local address, false otherwise
* @memberof Address6
* @instance
* @returns {boolean}
*/
isLinkLocal(): boolean;
/**
* Returns true if the address is a multicast address, false otherwise
* @memberof Address6
* @instance
* @returns {boolean}
*/
isMulticast(): boolean;
/**
* Returns true if the address is a v4-in-v6 address, false otherwise
* @memberof Address6
* @instance
* @returns {boolean}
*/
is4(): boolean;
/**
* Returns true if the address is a Teredo address, false otherwise
* @memberof Address6
* @instance
* @returns {boolean}
*/
isTeredo(): boolean;
/**
* Returns true if the address is a 6to4 address, false otherwise
* @memberof Address6
* @instance
* @returns {boolean}
*/
is6to4(): boolean;
/**
* Returns true if the address is a loopback address, false otherwise
* @memberof Address6
* @instance
* @returns {boolean}
*/
isLoopback(): boolean;
/**
* @returns {String} the address in link form with a default port of 80
*/
href(optionalPort?: number | string): string;
/**
* @returns {String} a link suitable for conveying the address via a URL hash
*/
link(options?: {
className?: string;
prefix?: string;
v4?: boolean;
}): string;
/**
* Groups an address
* @returns {String}
*/
group(): string;
/**
* Generate a regular expression string that can be used to find or validate
* all variations of this address
* @memberof Address6
* @instance
* @param {boolean} substringSearch
* @returns {string}
*/
regularExpressionString(this: Address6, substringSearch?: boolean): string;
/**
* Generate a regular expression that can be used to find or validate all
* variations of this address.
* @memberof Address6
* @instance
* @param {boolean} substringSearch
* @returns {RegExp}
*/
regularExpression(this: Address6, substringSearch?: boolean): RegExp;
}
export {};
//# sourceMappingURL=ipv6.d.ts.map

1
node_modules/ip-address/dist/ipv6.d.ts.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"ipv6.d.ts","sourceRoot":"","sources":["../src/ipv6.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAInC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAOlC,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAuDlC,UAAU,mBAAmB;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,C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IACH,KAAK,IAAI,MAAM;IA8Cf;;;;;;;OAOG;IACH,uBAAuB,CAAC,IAAI,EAAE,QAAQ,EAAE,eAAe,GAAE,OAAe,GAAG,MAAM;IAgDjF;;;;;;;OAOG;IACH,iBAAiB,CAAC,IAAI,EAAE,QAAQ,EAAE,eAAe,GAAE,OAAe,GAAG,MAAM;CAI5E"}

998
node_modules/ip-address/dist/ipv6.js generated vendored Normal file
View file

@ -0,0 +1,998 @@
"use strict";
/* eslint-disable prefer-destructuring */
/* eslint-disable no-param-reassign */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Address6 = void 0;
const common = __importStar(require("./common"));
const constants4 = __importStar(require("./v4/constants"));
const constants6 = __importStar(require("./v6/constants"));
const helpers = __importStar(require("./v6/helpers"));
const ipv4_1 = require("./ipv4");
const regular_expressions_1 = require("./v6/regular-expressions");
const address_error_1 = require("./address-error");
const jsbn_1 = require("jsbn");
const sprintf_js_1 = require("sprintf-js");
function assert(condition) {
if (!condition) {
throw new Error('Assertion failed.');
}
}
function addCommas(number) {
const r = /(\d+)(\d{3})/;
while (r.test(number)) {
number = number.replace(r, '$1,$2');
}
return number;
}
function spanLeadingZeroes4(n) {
n = n.replace(/^(0{1,})([1-9]+)$/, '<span class="parse-error">$1</span>$2');
n = n.replace(/^(0{1,})(0)$/, '<span class="parse-error">$1</span>$2');
return n;
}
/*
* A helper function to compact an array
*/
function compact(address, slice) {
const s1 = [];
const s2 = [];
let i;
for (i = 0; i < address.length; i++) {
if (i < slice[0]) {
s1.push(address[i]);
}
else if (i > slice[1]) {
s2.push(address[i]);
}
}
return s1.concat(['compact']).concat(s2);
}
function paddedHex(octet) {
return (0, sprintf_js_1.sprintf)('%04x', parseInt(octet, 16));
}
function unsignByte(b) {
// eslint-disable-next-line no-bitwise
return b & 0xff;
}
/**
* Represents an IPv6 address
* @class Address6
* @param {string} address - An IPv6 address string
* @param {number} [groups=8] - How many octets to parse
* @example
* var address = new Address6('2001::/32');
*/
class Address6 {
constructor(address, optionalGroups) {
this.addressMinusSuffix = '';
this.parsedSubnet = '';
this.subnet = '/128';
this.subnetMask = 128;
this.v4 = false;
this.zone = '';
// #region Attributes
/**
* Returns true if the given address is in the subnet of the current address
* @memberof Address6
* @instance
* @returns {boolean}
*/
this.isInSubnet = common.isInSubnet;
/**
* Returns true if the address is correct, false otherwise
* @memberof Address6
* @instance
* @returns {boolean}
*/
this.isCorrect = common.isCorrect(constants6.BITS);
if (optionalGroups === undefined) {
this.groups = constants6.GROUPS;
}
else {
this.groups = optionalGroups;
}
this.address = address;
const subnet = constants6.RE_SUBNET_STRING.exec(address);
if (subnet) {
this.parsedSubnet = subnet[0].replace('/', '');
this.subnetMask = parseInt(this.parsedSubnet, 10);
this.subnet = `/${this.subnetMask}`;
if (Number.isNaN(this.subnetMask) ||
this.subnetMask < 0 ||
this.subnetMask > constants6.BITS) {
throw new address_error_1.AddressError('Invalid subnet mask.');
}
address = address.replace(constants6.RE_SUBNET_STRING, '');
}
else if (/\//.test(address)) {
throw new address_error_1.AddressError('Invalid subnet mask.');
}
const zone = constants6.RE_ZONE_STRING.exec(address);
if (zone) {
this.zone = zone[0];
address = address.replace(constants6.RE_ZONE_STRING, '');
}
this.addressMinusSuffix = address;
this.parsedAddress = this.parse(this.addressMinusSuffix);
}
static isValid(address) {
try {
// eslint-disable-next-line no-new
new Address6(address);
return true;
}
catch (e) {
return false;
}
}
/**
* Convert a BigInteger to a v6 address object
* @memberof Address6
* @static
* @param {BigInteger} bigInteger - a BigInteger to convert
* @returns {Address6}
* @example
* var bigInteger = new BigInteger('1000000000000');
* var address = Address6.fromBigInteger(bigInteger);
* address.correctForm(); // '::e8:d4a5:1000'
*/
static fromBigInteger(bigInteger) {
const hex = bigInteger.toString(16).padStart(32, '0');
const groups = [];
let i;
for (i = 0; i < constants6.GROUPS; i++) {
groups.push(hex.slice(i * 4, (i + 1) * 4));
}
return new Address6(groups.join(':'));
}
/**
* Convert a URL (with optional port number) to an address object
* @memberof Address6
* @static
* @param {string} url - a URL with optional port number
* @example
* var addressAndPort = Address6.fromURL('http://[ffff::]:8080/foo/');
* addressAndPort.address.correctForm(); // 'ffff::'
* addressAndPort.port; // 8080
*/
static fromURL(url) {
let host;
let port = null;
let result;
// If we have brackets parse them and find a port
if (url.indexOf('[') !== -1 && url.indexOf(']:') !== -1) {
result = constants6.RE_URL_WITH_PORT.exec(url);
if (result === null) {
return {
error: 'failed to parse address with port',
address: null,
port: null,
};
}
host = result[1];
port = result[2];
// If there's a URL extract the address
}
else if (url.indexOf('/') !== -1) {
// Remove the protocol prefix
url = url.replace(/^[a-z0-9]+:\/\//, '');
// Parse the address
result = constants6.RE_URL.exec(url);
if (result === null) {
return {
error: 'failed to parse address from URL',
address: null,
port: null,
};
}
host = result[1];
// Otherwise just assign the URL to the host and let the library parse it
}
else {
host = url;
}
// If there's a port convert it to an integer
if (port) {
port = parseInt(port, 10);
// squelch out of range ports
if (port < 0 || port > 65536) {
port = null;
}
}
else {
// Standardize `undefined` to `null`
port = null;
}
return {
address: new Address6(host),
port,
};
}
/**
* Create an IPv6-mapped address given an IPv4 address
* @memberof Address6
* @static
* @param {string} address - An IPv4 address string
* @returns {Address6}
* @example
* var address = Address6.fromAddress4('192.168.0.1');
* address.correctForm(); // '::ffff:c0a8:1'
* address.to4in6(); // '::ffff:192.168.0.1'
*/
static fromAddress4(address) {
const address4 = new ipv4_1.Address4(address);
const mask6 = constants6.BITS - (constants4.BITS - address4.subnetMask);
return new Address6(`::ffff:${address4.correctForm()}/${mask6}`);
}
/**
* Return an address from ip6.arpa form
* @memberof Address6
* @static
* @param {string} arpaFormAddress - an 'ip6.arpa' form address
* @returns {Adress6}
* @example
* var address = Address6.fromArpa(e.f.f.f.3.c.2.6.f.f.f.e.6.6.8.e.1.0.6.7.9.4.e.c.0.0.0.0.1.0.0.2.ip6.arpa.)
* address.correctForm(); // '2001:0:ce49:7601:e866:efff:62c3:fffe'
*/
static fromArpa(arpaFormAddress) {
// remove ending ".ip6.arpa." or just "."
let address = arpaFormAddress.replace(/(\.ip6\.arpa)?\.$/, '');
const semicolonAmount = 7;
// correct ip6.arpa form with ending removed will be 63 characters
if (address.length !== 63) {
throw new address_error_1.AddressError("Invalid 'ip6.arpa' form.");
}
const parts = address.split('.').reverse();
for (let i = semicolonAmount; i > 0; i--) {
const insertIndex = i * 4;
parts.splice(insertIndex, 0, ':');
}
address = parts.join('');
return new Address6(address);
}
/**
* Return the Microsoft UNC transcription of the address
* @memberof Address6
* @instance
* @returns {String} the Microsoft UNC transcription of the address
*/
microsoftTranscription() {
return (0, sprintf_js_1.sprintf)('%s.ipv6-literal.net', this.correctForm().replace(/:/g, '-'));
}
/**
* Return the first n bits of the address, defaulting to the subnet mask
* @memberof Address6
* @instance
* @param {number} [mask=subnet] - the number of bits to mask
* @returns {String} the first n bits of the address as a string
*/
mask(mask = this.subnetMask) {
return this.getBitsBase2(0, mask);
}
/**
* Return the number of possible subnets of a given size in the address
* @memberof Address6
* @instance
* @param {number} [size=128] - the subnet size
* @returns {String}
*/
// TODO: probably useful to have a numeric version of this too
possibleSubnets(subnetSize = 128) {
const availableBits = constants6.BITS - this.subnetMask;
const subnetBits = Math.abs(subnetSize - constants6.BITS);
const subnetPowers = availableBits - subnetBits;
if (subnetPowers < 0) {
return '0';
}
return addCommas(new jsbn_1.BigInteger('2', 10).pow(subnetPowers).toString(10));
}
/**
* Helper function getting start address.
* @memberof Address6
* @instance
* @returns {BigInteger}
*/
_startAddress() {
return new jsbn_1.BigInteger(this.mask() + '0'.repeat(constants6.BITS - this.subnetMask), 2);
}
/**
* The first address in the range given by this address' subnet
* Often referred to as the Network Address.
* @memberof Address6
* @instance
* @returns {Address6}
*/
startAddress() {
return Address6.fromBigInteger(this._startAddress());
}
/**
* The first host address in the range given by this address's subnet ie
* the first address after the Network Address
* @memberof Address6
* @instance
* @returns {Address6}
*/
startAddressExclusive() {
const adjust = new jsbn_1.BigInteger('1');
return Address6.fromBigInteger(this._startAddress().add(adjust));
}
/**
* Helper function getting end address.
* @memberof Address6
* @instance
* @returns {BigInteger}
*/
_endAddress() {
return new jsbn_1.BigInteger(this.mask() + '1'.repeat(constants6.BITS - this.subnetMask), 2);
}
/**
* The last address in the range given by this address' subnet
* Often referred to as the Broadcast
* @memberof Address6
* @instance
* @returns {Address6}
*/
endAddress() {
return Address6.fromBigInteger(this._endAddress());
}
/**
* The last host address in the range given by this address's subnet ie
* the last address prior to the Broadcast Address
* @memberof Address6
* @instance
* @returns {Address6}
*/
endAddressExclusive() {
const adjust = new jsbn_1.BigInteger('1');
return Address6.fromBigInteger(this._endAddress().subtract(adjust));
}
/**
* Return the scope of the address
* @memberof Address6
* @instance
* @returns {String}
*/
getScope() {
let scope = constants6.SCOPES[this.getBits(12, 16).intValue()];
if (this.getType() === 'Global unicast' && scope !== 'Link local') {
scope = 'Global';
}
return scope || 'Unknown';
}
/**
* Return the type of the address
* @memberof Address6
* @instance
* @returns {String}
*/
getType() {
for (const subnet of Object.keys(constants6.TYPES)) {
if (this.isInSubnet(new Address6(subnet))) {
return constants6.TYPES[subnet];
}
}
return 'Global unicast';
}
/**
* Return the bits in the given range as a BigInteger
* @memberof Address6
* @instance
* @returns {BigInteger}
*/
getBits(start, end) {
return new jsbn_1.BigInteger(this.getBitsBase2(start, end), 2);
}
/**
* Return the bits in the given range as a base-2 string
* @memberof Address6
* @instance
* @returns {String}
*/
getBitsBase2(start, end) {
return this.binaryZeroPad().slice(start, end);
}
/**
* Return the bits in the given range as a base-16 string
* @memberof Address6
* @instance
* @returns {String}
*/
getBitsBase16(start, end) {
const length = end - start;
if (length % 4 !== 0) {
throw new Error('Length of bits to retrieve must be divisible by four');
}
return this.getBits(start, end)
.toString(16)
.padStart(length / 4, '0');
}
/**
* Return the bits that are set past the subnet mask length
* @memberof Address6
* @instance
* @returns {String}
*/
getBitsPastSubnet() {
return this.getBitsBase2(this.subnetMask, constants6.BITS);
}
/**
* Return the reversed ip6.arpa form of the address
* @memberof Address6
* @param {Object} options
* @param {boolean} options.omitSuffix - omit the "ip6.arpa" suffix
* @instance
* @returns {String}
*/
reverseForm(options) {
if (!options) {
options = {};
}
const characters = Math.floor(this.subnetMask / 4);
const reversed = this.canonicalForm()
.replace(/:/g, '')
.split('')
.slice(0, characters)
.reverse()
.join('.');
if (characters > 0) {
if (options.omitSuffix) {
return reversed;
}
return (0, sprintf_js_1.sprintf)('%s.ip6.arpa.', reversed);
}
if (options.omitSuffix) {
return '';
}
return 'ip6.arpa.';
}
/**
* Return the correct form of the address
* @memberof Address6
* @instance
* @returns {String}
*/
correctForm() {
let i;
let groups = [];
let zeroCounter = 0;
const zeroes = [];
for (i = 0; i < this.parsedAddress.length; i++) {
const value = parseInt(this.parsedAddress[i], 16);
if (value === 0) {
zeroCounter++;
}
if (value !== 0 && zeroCounter > 0) {
if (zeroCounter > 1) {
zeroes.push([i - zeroCounter, i - 1]);
}
zeroCounter = 0;
}
}
// Do we end with a string of zeroes?
if (zeroCounter > 1) {
zeroes.push([this.parsedAddress.length - zeroCounter, this.parsedAddress.length - 1]);
}
const zeroLengths = zeroes.map((n) => n[1] - n[0] + 1);
if (zeroes.length > 0) {
const index = zeroLengths.indexOf(Math.max(...zeroLengths));
groups = compact(this.parsedAddress, zeroes[index]);
}
else {
groups = this.parsedAddress;
}
for (i = 0; i < groups.length; i++) {
if (groups[i] !== 'compact') {
groups[i] = parseInt(groups[i], 16).toString(16);
}
}
let correct = groups.join(':');
correct = correct.replace(/^compact$/, '::');
correct = correct.replace(/^compact|compact$/, ':');
correct = correct.replace(/compact/, '');
return correct;
}
/**
* Return a zero-padded base-2 string representation of the address
* @memberof Address6
* @instance
* @returns {String}
* @example
* var address = new Address6('2001:4860:4001:803::1011');
* address.binaryZeroPad();
* // '0010000000000001010010000110000001000000000000010000100000000011
* // 0000000000000000000000000000000000000000000000000001000000010001'
*/
binaryZeroPad() {
return this.bigInteger().toString(2).padStart(constants6.BITS, '0');
}
// TODO: Improve the semantics of this helper function
parse4in6(address) {
const groups = address.split(':');
const lastGroup = groups.slice(-1)[0];
const address4 = lastGroup.match(constants4.RE_ADDRESS);
if (address4) {
this.parsedAddress4 = address4[0];
this.address4 = new ipv4_1.Address4(this.parsedAddress4);
for (let i = 0; i < this.address4.groups; i++) {
if (/^0[0-9]+/.test(this.address4.parsedAddress[i])) {
throw new address_error_1.AddressError("IPv4 addresses can't have leading zeroes.", address.replace(constants4.RE_ADDRESS, this.address4.parsedAddress.map(spanLeadingZeroes4).join('.')));
}
}
this.v4 = true;
groups[groups.length - 1] = this.address4.toGroup6();
address = groups.join(':');
}
return address;
}
// TODO: Make private?
parse(address) {
address = this.parse4in6(address);
const badCharacters = address.match(constants6.RE_BAD_CHARACTERS);
if (badCharacters) {
throw new address_error_1.AddressError((0, sprintf_js_1.sprintf)('Bad character%s detected in address: %s', badCharacters.length > 1 ? 's' : '', badCharacters.join('')), address.replace(constants6.RE_BAD_CHARACTERS, '<span class="parse-error">$1</span>'));
}
const badAddress = address.match(constants6.RE_BAD_ADDRESS);
if (badAddress) {
throw new address_error_1.AddressError((0, sprintf_js_1.sprintf)('Address failed regex: %s', badAddress.join('')), address.replace(constants6.RE_BAD_ADDRESS, '<span class="parse-error">$1</span>'));
}
let groups = [];
const halves = address.split('::');
if (halves.length === 2) {
let first = halves[0].split(':');
let last = halves[1].split(':');
if (first.length === 1 && first[0] === '') {
first = [];
}
if (last.length === 1 && last[0] === '') {
last = [];
}
const remaining = this.groups - (first.length + last.length);
if (!remaining) {
throw new address_error_1.AddressError('Error parsing groups');
}
this.elidedGroups = remaining;
this.elisionBegin = first.length;
this.elisionEnd = first.length + this.elidedGroups;
groups = groups.concat(first);
for (let i = 0; i < remaining; i++) {
groups.push('0');
}
groups = groups.concat(last);
}
else if (halves.length === 1) {
groups = address.split(':');
this.elidedGroups = 0;
}
else {
throw new address_error_1.AddressError('Too many :: groups found');
}
groups = groups.map((group) => (0, sprintf_js_1.sprintf)('%x', parseInt(group, 16)));
if (groups.length !== this.groups) {
throw new address_error_1.AddressError('Incorrect number of groups found');
}
return groups;
}
/**
* Return the canonical form of the address
* @memberof Address6
* @instance
* @returns {String}
*/
canonicalForm() {
return this.parsedAddress.map(paddedHex).join(':');
}
/**
* Return the decimal form of the address
* @memberof Address6
* @instance
* @returns {String}
*/
decimal() {
return this.parsedAddress.map((n) => (0, sprintf_js_1.sprintf)('%05d', parseInt(n, 16))).join(':');
}
/**
* Return the address as a BigInteger
* @memberof Address6
* @instance
* @returns {BigInteger}
*/
bigInteger() {
return new jsbn_1.BigInteger(this.parsedAddress.map(paddedHex).join(''), 16);
}
/**
* Return the last two groups of this address as an IPv4 address string
* @memberof Address6
* @instance
* @returns {Address4}
* @example
* var address = new Address6('2001:4860:4001::1825:bf11');
* address.to4().correctForm(); // '24.37.191.17'
*/
to4() {
const binary = this.binaryZeroPad().split('');
return ipv4_1.Address4.fromHex(new jsbn_1.BigInteger(binary.slice(96, 128).join(''), 2).toString(16));
}
/**
* Return the v4-in-v6 form of the address
* @memberof Address6
* @instance
* @returns {String}
*/
to4in6() {
const address4 = this.to4();
const address6 = new Address6(this.parsedAddress.slice(0, 6).join(':'), 6);
const correct = address6.correctForm();
let infix = '';
if (!/:$/.test(correct)) {
infix = ':';
}
return correct + infix + address4.address;
}
/**
* Return an object containing the Teredo properties of the address
* @memberof Address6
* @instance
* @returns {Object}
*/
inspectTeredo() {
/*
- Bits 0 to 31 are set to the Teredo prefix (normally 2001:0000::/32).
- Bits 32 to 63 embed the primary IPv4 address of the Teredo server that
is used.
- Bits 64 to 79 can be used to define some flags. Currently only the
higher order bit is used; it is set to 1 if the Teredo client is
located behind a cone NAT, 0 otherwise. For Microsoft's Windows Vista
and Windows Server 2008 implementations, more bits are used. In those
implementations, the format for these 16 bits is "CRAAAAUG AAAAAAAA",
where "C" remains the "Cone" flag. The "R" bit is reserved for future
use. The "U" bit is for the Universal/Local flag (set to 0). The "G" bit
is Individual/Group flag (set to 0). The A bits are set to a 12-bit
randomly generated number chosen by the Teredo client to introduce
additional protection for the Teredo node against IPv6-based scanning
attacks.
- Bits 80 to 95 contains the obfuscated UDP port number. This is the
port number that is mapped by the NAT to the Teredo client with all
bits inverted.
- Bits 96 to 127 contains the obfuscated IPv4 address. This is the
public IPv4 address of the NAT with all bits inverted.
*/
const prefix = this.getBitsBase16(0, 32);
const udpPort = this.getBits(80, 96).xor(new jsbn_1.BigInteger('ffff', 16)).toString();
const server4 = ipv4_1.Address4.fromHex(this.getBitsBase16(32, 64));
const client4 = ipv4_1.Address4.fromHex(this.getBits(96, 128).xor(new jsbn_1.BigInteger('ffffffff', 16)).toString(16));
const flags = this.getBits(64, 80);
const flagsBase2 = this.getBitsBase2(64, 80);
const coneNat = flags.testBit(15);
const reserved = flags.testBit(14);
const groupIndividual = flags.testBit(8);
const universalLocal = flags.testBit(9);
const nonce = new jsbn_1.BigInteger(flagsBase2.slice(2, 6) + flagsBase2.slice(8, 16), 2).toString(10);
return {
prefix: (0, sprintf_js_1.sprintf)('%s:%s', prefix.slice(0, 4), prefix.slice(4, 8)),
server4: server4.address,
client4: client4.address,
flags: flagsBase2,
coneNat,
microsoft: {
reserved,
universalLocal,
groupIndividual,
nonce,
},
udpPort,
};
}
/**
* Return an object containing the 6to4 properties of the address
* @memberof Address6
* @instance
* @returns {Object}
*/
inspect6to4() {
/*
- Bits 0 to 15 are set to the 6to4 prefix (2002::/16).
- Bits 16 to 48 embed the IPv4 address of the 6to4 gateway that is used.
*/
const prefix = this.getBitsBase16(0, 16);
const gateway = ipv4_1.Address4.fromHex(this.getBitsBase16(16, 48));
return {
prefix: (0, sprintf_js_1.sprintf)('%s', prefix.slice(0, 4)),
gateway: gateway.address,
};
}
/**
* Return a v6 6to4 address from a v6 v4inv6 address
* @memberof Address6
* @instance
* @returns {Address6}
*/
to6to4() {
if (!this.is4()) {
return null;
}
const addr6to4 = [
'2002',
this.getBitsBase16(96, 112),
this.getBitsBase16(112, 128),
'',
'/16',
].join(':');
return new Address6(addr6to4);
}
/**
* Return a byte array
* @memberof Address6
* @instance
* @returns {Array}
*/
toByteArray() {
const byteArray = this.bigInteger().toByteArray();
// work around issue where `toByteArray` returns a leading 0 element
if (byteArray.length === 17 && byteArray[0] === 0) {
return byteArray.slice(1);
}
return byteArray;
}
/**
* Return an unsigned byte array
* @memberof Address6
* @instance
* @returns {Array}
*/
toUnsignedByteArray() {
return this.toByteArray().map(unsignByte);
}
/**
* Convert a byte array to an Address6 object
* @memberof Address6
* @static
* @returns {Address6}
*/
static fromByteArray(bytes) {
return this.fromUnsignedByteArray(bytes.map(unsignByte));
}
/**
* Convert an unsigned byte array to an Address6 object
* @memberof Address6
* @static
* @returns {Address6}
*/
static fromUnsignedByteArray(bytes) {
const BYTE_MAX = new jsbn_1.BigInteger('256', 10);
let result = new jsbn_1.BigInteger('0', 10);
let multiplier = new jsbn_1.BigInteger('1', 10);
for (let i = bytes.length - 1; i >= 0; i--) {
result = result.add(multiplier.multiply(new jsbn_1.BigInteger(bytes[i].toString(10), 10)));
multiplier = multiplier.multiply(BYTE_MAX);
}
return Address6.fromBigInteger(result);
}
/**
* Returns true if the address is in the canonical form, false otherwise
* @memberof Address6
* @instance
* @returns {boolean}
*/
isCanonical() {
return this.addressMinusSuffix === this.canonicalForm();
}
/**
* Returns true if the address is a link local address, false otherwise
* @memberof Address6
* @instance
* @returns {boolean}
*/
isLinkLocal() {
// Zeroes are required, i.e. we can't check isInSubnet with 'fe80::/10'
if (this.getBitsBase2(0, 64) ===
'1111111010000000000000000000000000000000000000000000000000000000') {
return true;
}
return false;
}
/**
* Returns true if the address is a multicast address, false otherwise
* @memberof Address6
* @instance
* @returns {boolean}
*/
isMulticast() {
return this.getType() === 'Multicast';
}
/**
* Returns true if the address is a v4-in-v6 address, false otherwise
* @memberof Address6
* @instance
* @returns {boolean}
*/
is4() {
return this.v4;
}
/**
* Returns true if the address is a Teredo address, false otherwise
* @memberof Address6
* @instance
* @returns {boolean}
*/
isTeredo() {
return this.isInSubnet(new Address6('2001::/32'));
}
/**
* Returns true if the address is a 6to4 address, false otherwise
* @memberof Address6
* @instance
* @returns {boolean}
*/
is6to4() {
return this.isInSubnet(new Address6('2002::/16'));
}
/**
* Returns true if the address is a loopback address, false otherwise
* @memberof Address6
* @instance
* @returns {boolean}
*/
isLoopback() {
return this.getType() === 'Loopback';
}
// #endregion
// #region HTML
/**
* @returns {String} the address in link form with a default port of 80
*/
href(optionalPort) {
if (optionalPort === undefined) {
optionalPort = '';
}
else {
optionalPort = (0, sprintf_js_1.sprintf)(':%s', optionalPort);
}
return (0, sprintf_js_1.sprintf)('http://[%s]%s/', this.correctForm(), optionalPort);
}
/**
* @returns {String} a link suitable for conveying the address via a URL hash
*/
link(options) {
if (!options) {
options = {};
}
if (options.className === undefined) {
options.className = '';
}
if (options.prefix === undefined) {
options.prefix = '/#address=';
}
if (options.v4 === undefined) {
options.v4 = false;
}
let formFunction = this.correctForm;
if (options.v4) {
formFunction = this.to4in6;
}
if (options.className) {
return (0, sprintf_js_1.sprintf)('<a href="%1$s%2$s" class="%3$s">%2$s</a>', options.prefix, formFunction.call(this), options.className);
}
return (0, sprintf_js_1.sprintf)('<a href="%1$s%2$s">%2$s</a>', options.prefix, formFunction.call(this));
}
/**
* Groups an address
* @returns {String}
*/
group() {
if (this.elidedGroups === 0) {
// The simple case
return helpers.simpleGroup(this.address).join(':');
}
assert(typeof this.elidedGroups === 'number');
assert(typeof this.elisionBegin === 'number');
// The elided case
const output = [];
const [left, right] = this.address.split('::');
if (left.length) {
output.push(...helpers.simpleGroup(left));
}
else {
output.push('');
}
const classes = ['hover-group'];
for (let i = this.elisionBegin; i < this.elisionBegin + this.elidedGroups; i++) {
classes.push((0, sprintf_js_1.sprintf)('group-%d', i));
}
output.push((0, sprintf_js_1.sprintf)('<span class="%s"></span>', classes.join(' ')));
if (right.length) {
output.push(...helpers.simpleGroup(right, this.elisionEnd));
}
else {
output.push('');
}
if (this.is4()) {
assert(this.address4 instanceof ipv4_1.Address4);
output.pop();
output.push(this.address4.groupForV6());
}
return output.join(':');
}
// #endregion
// #region Regular expressions
/**
* Generate a regular expression string that can be used to find or validate
* all variations of this address
* @memberof Address6
* @instance
* @param {boolean} substringSearch
* @returns {string}
*/
regularExpressionString(substringSearch = false) {
let output = [];
// TODO: revisit why this is necessary
const address6 = new Address6(this.correctForm());
if (address6.elidedGroups === 0) {
// The simple case
output.push((0, regular_expressions_1.simpleRegularExpression)(address6.parsedAddress));
}
else if (address6.elidedGroups === constants6.GROUPS) {
// A completely elided address
output.push((0, regular_expressions_1.possibleElisions)(constants6.GROUPS));
}
else {
// A partially elided address
const halves = address6.address.split('::');
if (halves[0].length) {
output.push((0, regular_expressions_1.simpleRegularExpression)(halves[0].split(':')));
}
assert(typeof address6.elidedGroups === 'number');
output.push((0, regular_expressions_1.possibleElisions)(address6.elidedGroups, halves[0].length !== 0, halves[1].length !== 0));
if (halves[1].length) {
output.push((0, regular_expressions_1.simpleRegularExpression)(halves[1].split(':')));
}
output = [output.join(':')];
}
if (!substringSearch) {
output = [
'(?=^|',
regular_expressions_1.ADDRESS_BOUNDARY,
'|[^\\w\\:])(',
...output,
')(?=[^\\w\\:]|',
regular_expressions_1.ADDRESS_BOUNDARY,
'|$)',
];
}
return output.join('');
}
/**
* Generate a regular expression that can be used to find or validate all
* variations of this address.
* @memberof Address6
* @instance
* @param {boolean} substringSearch
* @returns {RegExp}
*/
regularExpression(substringSearch = false) {
return new RegExp(this.regularExpressionString(substringSearch), 'i');
}
}
exports.Address6 = Address6;
//# sourceMappingURL=ipv6.js.map

1
node_modules/ip-address/dist/ipv6.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

5
node_modules/ip-address/dist/v4/constants.d.ts generated vendored Normal file
View file

@ -0,0 +1,5 @@
export declare const BITS = 32;
export declare const GROUPS = 4;
export declare const RE_ADDRESS: RegExp;
export declare const RE_SUBNET_STRING: RegExp;
//# sourceMappingURL=constants.d.ts.map

1
node_modules/ip-address/dist/v4/constants.d.ts.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/v4/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,KAAK,CAAC;AACvB,eAAO,MAAM,MAAM,IAAI,CAAC;AAExB,eAAO,MAAM,UAAU,QAAsK,CAAC;AAE9L,eAAO,MAAM,gBAAgB,QAAe,CAAC"}

8
node_modules/ip-address/dist/v4/constants.js generated vendored Normal file
View file

@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RE_SUBNET_STRING = exports.RE_ADDRESS = exports.GROUPS = exports.BITS = void 0;
exports.BITS = 32;
exports.GROUPS = 4;
exports.RE_ADDRESS = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g;
exports.RE_SUBNET_STRING = /\/\d{1,2}$/;
//# sourceMappingURL=constants.js.map

1
node_modules/ip-address/dist/v4/constants.js.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/v4/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,IAAI,GAAG,EAAE,CAAC;AACV,QAAA,MAAM,GAAG,CAAC,CAAC;AAEX,QAAA,UAAU,GAAG,mKAAmK,CAAC;AAEjL,QAAA,gBAAgB,GAAG,YAAY,CAAC"}

45
node_modules/ip-address/dist/v6/constants.d.ts generated vendored Normal file
View file

@ -0,0 +1,45 @@
export declare const BITS = 128;
export declare const GROUPS = 8;
/**
* Represents IPv6 address scopes
* @memberof Address6
* @static
*/
export declare const SCOPES: {
[key: number]: string | undefined;
};
/**
* Represents IPv6 address types
* @memberof Address6
* @static
*/
export declare const TYPES: {
[key: string]: string | undefined;
};
/**
* A regular expression that matches bad characters in an IPv6 address
* @memberof Address6
* @static
*/
export declare const RE_BAD_CHARACTERS: RegExp;
/**
* A regular expression that matches an incorrect IPv6 address
* @memberof Address6
* @static
*/
export declare const RE_BAD_ADDRESS: RegExp;
/**
* A regular expression that matches an IPv6 subnet
* @memberof Address6
* @static
*/
export declare const RE_SUBNET_STRING: RegExp;
/**
* A regular expression that matches an IPv6 zone
* @memberof Address6
* @static
*/
export declare const RE_ZONE_STRING: RegExp;
export declare const RE_URL: RegExp;
export declare const RE_URL_WITH_PORT: RegExp;
//# sourceMappingURL=constants.d.ts.map

1
node_modules/ip-address/dist/v6/constants.d.ts.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/v6/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,MAAM,CAAC;AACxB,eAAO,MAAM,MAAM,IAAI,CAAC;AAExB;;;;GAIG;AACH,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CAS9C,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,KAAK,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CAuB7C,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QAAqB,CAAC;AAEpD;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAA6C,CAAC;AAEzE;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,QAAqB,CAAC;AAEnD;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAS,CAAC;AAErC,eAAO,MAAM,MAAM,QAA4C,CAAC;AAChE,eAAO,MAAM,gBAAgB,QAA8C,CAAC"}

76
node_modules/ip-address/dist/v6/constants.js generated vendored Normal file
View file

@ -0,0 +1,76 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RE_URL_WITH_PORT = exports.RE_URL = exports.RE_ZONE_STRING = exports.RE_SUBNET_STRING = exports.RE_BAD_ADDRESS = exports.RE_BAD_CHARACTERS = exports.TYPES = exports.SCOPES = exports.GROUPS = exports.BITS = void 0;
exports.BITS = 128;
exports.GROUPS = 8;
/**
* Represents IPv6 address scopes
* @memberof Address6
* @static
*/
exports.SCOPES = {
0: 'Reserved',
1: 'Interface local',
2: 'Link local',
4: 'Admin local',
5: 'Site local',
8: 'Organization local',
14: 'Global',
15: 'Reserved',
};
/**
* Represents IPv6 address types
* @memberof Address6
* @static
*/
exports.TYPES = {
'ff01::1/128': 'Multicast (All nodes on this interface)',
'ff01::2/128': 'Multicast (All routers on this interface)',
'ff02::1/128': 'Multicast (All nodes on this link)',
'ff02::2/128': 'Multicast (All routers on this link)',
'ff05::2/128': 'Multicast (All routers in this site)',
'ff02::5/128': 'Multicast (OSPFv3 AllSPF routers)',
'ff02::6/128': 'Multicast (OSPFv3 AllDR routers)',
'ff02::9/128': 'Multicast (RIP routers)',
'ff02::a/128': 'Multicast (EIGRP routers)',
'ff02::d/128': 'Multicast (PIM routers)',
'ff02::16/128': 'Multicast (MLDv2 reports)',
'ff01::fb/128': 'Multicast (mDNSv6)',
'ff02::fb/128': 'Multicast (mDNSv6)',
'ff05::fb/128': 'Multicast (mDNSv6)',
'ff02::1:2/128': 'Multicast (All DHCP servers and relay agents on this link)',
'ff05::1:2/128': 'Multicast (All DHCP servers and relay agents in this site)',
'ff02::1:3/128': 'Multicast (All DHCP servers on this link)',
'ff05::1:3/128': 'Multicast (All DHCP servers in this site)',
'::/128': 'Unspecified',
'::1/128': 'Loopback',
'ff00::/8': 'Multicast',
'fe80::/10': 'Link-local unicast',
};
/**
* A regular expression that matches bad characters in an IPv6 address
* @memberof Address6
* @static
*/
exports.RE_BAD_CHARACTERS = /([^0-9a-f:/%])/gi;
/**
* A regular expression that matches an incorrect IPv6 address
* @memberof Address6
* @static
*/
exports.RE_BAD_ADDRESS = /([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi;
/**
* A regular expression that matches an IPv6 subnet
* @memberof Address6
* @static
*/
exports.RE_SUBNET_STRING = /\/\d{1,3}(?=%|$)/;
/**
* A regular expression that matches an IPv6 zone
* @memberof Address6
* @static
*/
exports.RE_ZONE_STRING = /%.*$/;
exports.RE_URL = new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/);
exports.RE_URL_WITH_PORT = new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/);
//# sourceMappingURL=constants.js.map

1
node_modules/ip-address/dist/v6/constants.js.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/v6/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,IAAI,GAAG,GAAG,CAAC;AACX,QAAA,MAAM,GAAG,CAAC,CAAC;AAExB;;;;GAIG;AACU,QAAA,MAAM,GAA0C;IAC3D,CAAC,EAAE,UAAU;IACb,CAAC,EAAE,iBAAiB;IACpB,CAAC,EAAE,YAAY;IACf,CAAC,EAAE,aAAa;IAChB,CAAC,EAAE,YAAY;IACf,CAAC,EAAE,oBAAoB;IACvB,EAAE,EAAE,QAAQ;IACZ,EAAE,EAAE,UAAU;CACN,CAAC;AAEX;;;;GAIG;AACU,QAAA,KAAK,GAA0C;IAC1D,aAAa,EAAE,yCAAyC;IACxD,aAAa,EAAE,2CAA2C;IAC1D,aAAa,EAAE,oCAAoC;IACnD,aAAa,EAAE,sCAAsC;IACrD,aAAa,EAAE,sCAAsC;IACrD,aAAa,EAAE,mCAAmC;IAClD,aAAa,EAAE,kCAAkC;IACjD,aAAa,EAAE,yBAAyB;IACxC,aAAa,EAAE,2BAA2B;IAC1C,aAAa,EAAE,yBAAyB;IACxC,cAAc,EAAE,2BAA2B;IAC3C,cAAc,EAAE,oBAAoB;IACpC,cAAc,EAAE,oBAAoB;IACpC,cAAc,EAAE,oBAAoB;IACpC,eAAe,EAAE,4DAA4D;IAC7E,eAAe,EAAE,4DAA4D;IAC7E,eAAe,EAAE,2CAA2C;IAC5D,eAAe,EAAE,2CAA2C;IAC5D,QAAQ,EAAE,aAAa;IACvB,SAAS,EAAE,UAAU;IACrB,UAAU,EAAE,WAAW;IACvB,WAAW,EAAE,oBAAoB;CACzB,CAAC;AAEX;;;;GAIG;AACU,QAAA,iBAAiB,GAAG,kBAAkB,CAAC;AAEpD;;;;GAIG;AACU,QAAA,cAAc,GAAG,0CAA0C,CAAC;AAEzE;;;;GAIG;AACU,QAAA,gBAAgB,GAAG,kBAAkB,CAAC;AAEnD;;;;GAIG;AACU,QAAA,cAAc,GAAG,MAAM,CAAC;AAExB,QAAA,MAAM,GAAG,IAAI,MAAM,CAAC,6BAA6B,CAAC,CAAC;AACnD,QAAA,gBAAgB,GAAG,IAAI,MAAM,CAAC,+BAA+B,CAAC,CAAC"}

18
node_modules/ip-address/dist/v6/helpers.d.ts generated vendored Normal file
View file

@ -0,0 +1,18 @@
/**
* @returns {String} the string with all zeroes contained in a <span>
*/
export declare function spanAllZeroes(s: string): string;
/**
* @returns {String} the string with each character contained in a <span>
*/
export declare function spanAll(s: string, offset?: number): string;
/**
* @returns {String} the string with leading zeroes contained in a <span>
*/
export declare function spanLeadingZeroes(address: string): string;
/**
* Groups an address
* @returns {String} a grouped address
*/
export declare function simpleGroup(addressString: string, offset?: number): string[];
//# sourceMappingURL=helpers.d.ts.map

1
node_modules/ip-address/dist/v6/helpers.d.ts.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/v6/helpers.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,GAAG,MAAM,CAc7D;AAMD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAIzD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,GAAG,MAAM,EAAE,CAc/E"}

48
node_modules/ip-address/dist/v6/helpers.js generated vendored Normal file
View file

@ -0,0 +1,48 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.simpleGroup = exports.spanLeadingZeroes = exports.spanAll = exports.spanAllZeroes = void 0;
const sprintf_js_1 = require("sprintf-js");
/**
* @returns {String} the string with all zeroes contained in a <span>
*/
function spanAllZeroes(s) {
return s.replace(/(0+)/g, '<span class="zero">$1</span>');
}
exports.spanAllZeroes = spanAllZeroes;
/**
* @returns {String} the string with each character contained in a <span>
*/
function spanAll(s, offset = 0) {
const letters = s.split('');
return letters
.map((n, i) => (0, sprintf_js_1.sprintf)('<span class="digit value-%s position-%d">%s</span>', n, i + offset, spanAllZeroes(n)) // XXX Use #base-2 .value-0 instead?
)
.join('');
}
exports.spanAll = spanAll;
function spanLeadingZeroesSimple(group) {
return group.replace(/^(0+)/, '<span class="zero">$1</span>');
}
/**
* @returns {String} the string with leading zeroes contained in a <span>
*/
function spanLeadingZeroes(address) {
const groups = address.split(':');
return groups.map((g) => spanLeadingZeroesSimple(g)).join(':');
}
exports.spanLeadingZeroes = spanLeadingZeroes;
/**
* Groups an address
* @returns {String} a grouped address
*/
function simpleGroup(addressString, offset = 0) {
const groups = addressString.split(':');
return groups.map((g, i) => {
if (/group-v4/.test(g)) {
return g;
}
return (0, sprintf_js_1.sprintf)('<span class="hover-group group-%d">%s</span>', i + offset, spanLeadingZeroesSimple(g));
});
}
exports.simpleGroup = simpleGroup;
//# sourceMappingURL=helpers.js.map

1
node_modules/ip-address/dist/v6/helpers.js.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/v6/helpers.ts"],"names":[],"mappings":";;;AAAA,2CAAqC;AAErC;;GAEG;AACH,SAAgB,aAAa,CAAC,CAAS;IACrC,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,8BAA8B,CAAC,CAAC;AAC5D,CAAC;AAFD,sCAEC;AAED;;GAEG;AACH,SAAgB,OAAO,CAAC,CAAS,EAAE,SAAiB,CAAC;IACnD,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAE5B,OAAO,OAAO;SACX,GAAG,CACF,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACP,IAAA,oBAAO,EACL,oDAAoD,EACpD,CAAC,EACD,CAAC,GAAG,MAAM,EACV,aAAa,CAAC,CAAC,CAAC,CACjB,CAAC,oCAAoC;KACzC;SACA,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAdD,0BAcC;AAED,SAAS,uBAAuB,CAAC,KAAa;IAC5C,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,8BAA8B,CAAC,CAAC;AAChE,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB,CAAC,OAAe;IAC/C,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAElC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACjE,CAAC;AAJD,8CAIC;AAED;;;GAGG;AACH,SAAgB,WAAW,CAAC,aAAqB,EAAE,SAAiB,CAAC;IACnE,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAExC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACzB,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YACtB,OAAO,CAAC,CAAC;SACV;QAED,OAAO,IAAA,oBAAO,EACZ,8CAA8C,EAC9C,CAAC,GAAG,MAAM,EACV,uBAAuB,CAAC,CAAC,CAAC,CAC3B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAdD,kCAcC"}

View file

@ -0,0 +1,6 @@
export declare function groupPossibilities(possibilities: string[]): string;
export declare function padGroup(group: string): string;
export declare const ADDRESS_BOUNDARY = "[^A-Fa-f0-9:]";
export declare function simpleRegularExpression(groups: string[]): string;
export declare function possibleElisions(elidedGroups: number, moreLeft?: boolean, moreRight?: boolean): string;
//# sourceMappingURL=regular-expressions.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"regular-expressions.d.ts","sourceRoot":"","sources":["../../src/v6/regular-expressions.ts"],"names":[],"mappings":"AAGA,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,MAAM,CAElE;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAM9C;AAED,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAEhD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,UA+BvD;AAED,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,OAAO,EAClB,SAAS,CAAC,EAAE,OAAO,GAClB,MAAM,CA4CR"}

96
node_modules/ip-address/dist/v6/regular-expressions.js generated vendored Normal file
View file

@ -0,0 +1,96 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.possibleElisions = exports.simpleRegularExpression = exports.ADDRESS_BOUNDARY = exports.padGroup = exports.groupPossibilities = void 0;
const v6 = __importStar(require("./constants"));
const sprintf_js_1 = require("sprintf-js");
function groupPossibilities(possibilities) {
return (0, sprintf_js_1.sprintf)('(%s)', possibilities.join('|'));
}
exports.groupPossibilities = groupPossibilities;
function padGroup(group) {
if (group.length < 4) {
return (0, sprintf_js_1.sprintf)('0{0,%d}%s', 4 - group.length, group);
}
return group;
}
exports.padGroup = padGroup;
exports.ADDRESS_BOUNDARY = '[^A-Fa-f0-9:]';
function simpleRegularExpression(groups) {
const zeroIndexes = [];
groups.forEach((group, i) => {
const groupInteger = parseInt(group, 16);
if (groupInteger === 0) {
zeroIndexes.push(i);
}
});
// You can technically elide a single 0, this creates the regular expressions
// to match that eventuality
const possibilities = zeroIndexes.map((zeroIndex) => groups
.map((group, i) => {
if (i === zeroIndex) {
const elision = i === 0 || i === v6.GROUPS - 1 ? ':' : '';
return groupPossibilities([padGroup(group), elision]);
}
return padGroup(group);
})
.join(':'));
// The simplest case
possibilities.push(groups.map(padGroup).join(':'));
return groupPossibilities(possibilities);
}
exports.simpleRegularExpression = simpleRegularExpression;
function possibleElisions(elidedGroups, moreLeft, moreRight) {
const left = moreLeft ? '' : ':';
const right = moreRight ? '' : ':';
const possibilities = [];
// 1. elision of everything (::)
if (!moreLeft && !moreRight) {
possibilities.push('::');
}
// 2. complete elision of the middle
if (moreLeft && moreRight) {
possibilities.push('');
}
if ((moreRight && !moreLeft) || (!moreRight && moreLeft)) {
// 3. complete elision of one side
possibilities.push(':');
}
// 4. elision from the left side
possibilities.push((0, sprintf_js_1.sprintf)('%s(:0{1,4}){1,%d}', left, elidedGroups - 1));
// 5. elision from the right side
possibilities.push((0, sprintf_js_1.sprintf)('(0{1,4}:){1,%d}%s', elidedGroups - 1, right));
// 6. no elision
possibilities.push((0, sprintf_js_1.sprintf)('(0{1,4}:){%d}0{1,4}', elidedGroups - 1));
// 7. elision (including sloppy elision) from the middle
for (let groups = 1; groups < elidedGroups - 1; groups++) {
for (let position = 1; position < elidedGroups - groups; position++) {
possibilities.push((0, sprintf_js_1.sprintf)('(0{1,4}:){%d}:(0{1,4}:){%d}0{1,4}', position, elidedGroups - position - groups - 1));
}
}
return groupPossibilities(possibilities);
}
exports.possibleElisions = possibleElisions;
//# sourceMappingURL=regular-expressions.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"regular-expressions.js","sourceRoot":"","sources":["../../src/v6/regular-expressions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,2CAAqC;AAErC,SAAgB,kBAAkB,CAAC,aAAuB;IACxD,OAAO,IAAA,oBAAO,EAAC,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAClD,CAAC;AAFD,gDAEC;AAED,SAAgB,QAAQ,CAAC,KAAa;IACpC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;QACpB,OAAO,IAAA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