Update, insert new ping method
Took 29 minutes
This commit is contained in:
106
node_modules/ip-address/lib/v6/attributes.js
generated
vendored
Normal file
106
node_modules/ip-address/lib/v6/attributes.js
generated
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
'use strict';
|
||||
|
||||
var common = require('../common.js');
|
||||
var v6 = require('./constants.js');
|
||||
|
||||
/**
|
||||
* Returns true if the address is valid, false otherwise
|
||||
* @memberof Address6
|
||||
* @instance
|
||||
* @returns {boolean}
|
||||
*/
|
||||
exports.isValid = function () {
|
||||
return this.valid;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the given address is in the subnet of the current address
|
||||
* @memberof Address6
|
||||
* @instance
|
||||
* @returns {boolean}
|
||||
*/
|
||||
exports.isInSubnet = common.isInSubnet;
|
||||
|
||||
/**
|
||||
* Returns true if the address is correct, false otherwise
|
||||
* @memberof Address6
|
||||
* @instance
|
||||
* @returns {boolean}
|
||||
*/
|
||||
exports.isCorrect = common.isCorrect(v6.BITS);
|
||||
|
||||
/**
|
||||
* Returns true if the address is in the canonical form, false otherwise
|
||||
* @memberof Address6
|
||||
* @instance
|
||||
* @returns {boolean}
|
||||
*/
|
||||
exports.isCanonical = common.falseIfInvalid(function () {
|
||||
return this.addressMinusSuffix === this.canonicalForm();
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns true if the address is a link local address, false otherwise
|
||||
* @memberof Address6
|
||||
* @instance
|
||||
* @returns {boolean}
|
||||
*/
|
||||
exports.isLinkLocal = common.falseIfInvalid(function () {
|
||||
// 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}
|
||||
*/
|
||||
exports.isMulticast = common.falseIfInvalid(function () {
|
||||
return this.getType() === 'Multicast';
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns true if the address is a v4-in-v6 address, false otherwise
|
||||
* @memberof Address6
|
||||
* @instance
|
||||
* @returns {boolean}
|
||||
*/
|
||||
exports.is4 = common.falseIfInvalid(function () {
|
||||
return this.v4;
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns true if the address is a Teredo address, false otherwise
|
||||
* @memberof Address6
|
||||
* @instance
|
||||
* @returns {boolean}
|
||||
*/
|
||||
exports.isTeredo = common.falseIfInvalid(function () {
|
||||
return this.isInSubnet(new this.constructor('2001::/32'));
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns true if the address is a 6to4 address, false otherwise
|
||||
* @memberof Address6
|
||||
* @instance
|
||||
* @returns {boolean}
|
||||
*/
|
||||
exports.is6to4 = common.falseIfInvalid(function () {
|
||||
return this.isInSubnet(new this.constructor('2002::/16'));
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns true if the address is a loopback address, false otherwise
|
||||
* @memberof Address6
|
||||
* @instance
|
||||
* @returns {boolean}
|
||||
*/
|
||||
exports.isLoopback = common.falseIfInvalid(function () {
|
||||
return this.getType() === 'Loopback';
|
||||
});
|
79
node_modules/ip-address/lib/v6/constants.js
generated
vendored
Normal file
79
node_modules/ip-address/lib/v6/constants.js
generated
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
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:\/%])/ig;
|
||||
|
||||
/**
|
||||
* A regular expression that matches an incorrect IPv6 address
|
||||
* @memberof Address6
|
||||
* @static
|
||||
*/
|
||||
exports.RE_BAD_ADDRESS = /([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/ig;
|
||||
|
||||
/**
|
||||
* 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})/);
|
64
node_modules/ip-address/lib/v6/helpers.js
generated
vendored
Normal file
64
node_modules/ip-address/lib/v6/helpers.js
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
'use strict';
|
||||
|
||||
var sprintf = require('sprintf-js').sprintf;
|
||||
|
||||
/**
|
||||
* @returns {String} the string with all zeroes contained in a <span>
|
||||
*/
|
||||
var spanAllZeroes = exports.spanAllZeroes = function (s) {
|
||||
return s.replace(/(0+)/g, '<span class="zero">$1</span>');
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {String} the string with each character contained in a <span>
|
||||
*/
|
||||
exports.spanAll = function (s, optionalOffset) {
|
||||
if (optionalOffset === undefined) {
|
||||
optionalOffset = 0;
|
||||
}
|
||||
|
||||
var letters = s.split('');
|
||||
|
||||
return letters.map(function (n, i) {
|
||||
return sprintf('<span class="digit value-%s position-%d">%s</span>', n,
|
||||
i + optionalOffset,
|
||||
spanAllZeroes(n)); // XXX Use #base-2 .value-0 instead?
|
||||
}).join('');
|
||||
};
|
||||
|
||||
function spanLeadingZeroesSimple(group) {
|
||||
return group.replace(/^(0+)/, '<span class="zero">$1</span>');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {String} the string with leading zeroes contained in a <span>
|
||||
*/
|
||||
exports.spanLeadingZeroes = function (address) {
|
||||
var groups = address.split(':');
|
||||
|
||||
return groups.map(function (g) {
|
||||
return spanLeadingZeroesSimple(g);
|
||||
}).join(':');
|
||||
};
|
||||
|
||||
/**
|
||||
* Groups an address
|
||||
* @returns {String} a grouped address
|
||||
*/
|
||||
exports.simpleGroup = function (addressString, offset) {
|
||||
var groups = addressString.split(':');
|
||||
|
||||
if (!offset) {
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
return groups.map(function (g, i) {
|
||||
if (/group-v4/.test(g)) {
|
||||
return g;
|
||||
}
|
||||
|
||||
return sprintf('<span class="hover-group group-%d">%s</span>',
|
||||
i + offset,
|
||||
spanLeadingZeroesSimple(g));
|
||||
}).join(':');
|
||||
};
|
107
node_modules/ip-address/lib/v6/html.js
generated
vendored
Normal file
107
node_modules/ip-address/lib/v6/html.js
generated
vendored
Normal file
@ -0,0 +1,107 @@
|
||||
'use strict';
|
||||
|
||||
var constants4 = require('../v4/constants.js');
|
||||
var helpers = require('./helpers.js');
|
||||
var sprintf = require('sprintf-js').sprintf;
|
||||
|
||||
/**
|
||||
* @returns {String} the address in link form with a default port of 80
|
||||
*/
|
||||
exports.href = function (optionalPort) {
|
||||
if (optionalPort === undefined) {
|
||||
optionalPort = '';
|
||||
} else {
|
||||
optionalPort = sprintf(':%s', optionalPort);
|
||||
}
|
||||
|
||||
return sprintf('http://[%s]%s/', this.correctForm(), optionalPort);
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {String} a link suitable for conveying the address via a URL hash
|
||||
*/
|
||||
exports.link = function (options) {
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
|
||||
if (options.className === undefined) {
|
||||
options.className = '';
|
||||
}
|
||||
|
||||
if (options.prefix === undefined) {
|
||||
options.prefix = '/#address=';
|
||||
}
|
||||
|
||||
if (options.v4 === undefined) {
|
||||
options.v4 = false;
|
||||
}
|
||||
|
||||
var formFunction = this.correctForm;
|
||||
|
||||
if (options.v4) {
|
||||
formFunction = this.to4in6;
|
||||
}
|
||||
|
||||
if (options.className) {
|
||||
return sprintf('<a href="%1$s%2$s" class="%3$s">%2$s</a>',
|
||||
options.prefix, formFunction.call(this), options.className);
|
||||
}
|
||||
|
||||
return sprintf('<a href="%1$s%2$s">%2$s</a>', options.prefix,
|
||||
formFunction.call(this));
|
||||
};
|
||||
|
||||
/**
|
||||
* Groups an address
|
||||
* @returns {String}
|
||||
*/
|
||||
exports.group = function () {
|
||||
var address4 = this.address.match(constants4.RE_ADDRESS);
|
||||
var i;
|
||||
|
||||
if (address4) {
|
||||
// The IPv4 case
|
||||
var segments = address4[0].split('.');
|
||||
|
||||
this.address = this.address.replace(constants4.RE_ADDRESS,
|
||||
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('.')));
|
||||
}
|
||||
|
||||
if (this.elidedGroups === 0) {
|
||||
// The simple case
|
||||
return helpers.simpleGroup(this.address);
|
||||
}
|
||||
|
||||
// The elided case
|
||||
var output = [];
|
||||
|
||||
var halves = this.address.split('::');
|
||||
|
||||
if (halves[0].length) {
|
||||
output.push(helpers.simpleGroup(halves[0]));
|
||||
} else {
|
||||
output.push('');
|
||||
}
|
||||
|
||||
var classes = ['hover-group'];
|
||||
|
||||
for (i = this.elisionBegin;
|
||||
i < this.elisionBegin + this.elidedGroups; i++) {
|
||||
classes.push(sprintf('group-%d', i));
|
||||
}
|
||||
|
||||
output.push(sprintf('<span class="%s"></span>', classes.join(' ')));
|
||||
|
||||
if (halves[1].length) {
|
||||
output.push(helpers.simpleGroup(halves[1], this.elisionEnd));
|
||||
} else {
|
||||
output.push('');
|
||||
}
|
||||
|
||||
return output.join(':');
|
||||
};
|
159
node_modules/ip-address/lib/v6/regular-expressions.js
generated
vendored
Normal file
159
node_modules/ip-address/lib/v6/regular-expressions.js
generated
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
'use strict';
|
||||
|
||||
var sprintf = require('sprintf-js').sprintf;
|
||||
|
||||
var v6 = require('./constants.js');
|
||||
|
||||
function groupPossibilities(possibilities) {
|
||||
return sprintf('(%s)', possibilities.join('|'));
|
||||
}
|
||||
|
||||
function padGroup(group) {
|
||||
if (group.length < 4) {
|
||||
return sprintf('0{0,%d}%s', 4 - group.length, group);
|
||||
}
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
var ADDRESS_BOUNDARY = '[^A-Fa-f0-9:]';
|
||||
|
||||
function simpleRegularExpression(groups) {
|
||||
var zeroIndexes = [];
|
||||
|
||||
groups.forEach(function (group, i) {
|
||||
var 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
|
||||
var possibilities = zeroIndexes.map(function (zeroIndex) {
|
||||
return groups.map(function (group, i) {
|
||||
if (i === zeroIndex) {
|
||||
var 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);
|
||||
}
|
||||
|
||||
function possibleElisions(elidedGroups, moreLeft, moreRight) {
|
||||
var left = moreLeft ? '' : ':';
|
||||
var right = moreRight ? '' : ':';
|
||||
|
||||
var 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(sprintf('%s(:0{1,4}){1,%d}', left, elidedGroups - 1));
|
||||
|
||||
// 5. elision from the right side
|
||||
possibilities.push(sprintf('(0{1,4}:){1,%d}%s', elidedGroups - 1, right));
|
||||
|
||||
// 6. no elision
|
||||
possibilities.push(sprintf('(0{1,4}:){%d}0{1,4}', elidedGroups - 1));
|
||||
|
||||
// 7. elision (including sloppy elision) from the middle
|
||||
for (var groups = 1; groups < elidedGroups - 1; groups++) {
|
||||
for (var position = 1; position < elidedGroups - groups; position++) {
|
||||
possibilities.push(sprintf('(0{1,4}:){%d}:(0{1,4}:){%d}0{1,4}',
|
||||
position,
|
||||
elidedGroups - position - groups - 1));
|
||||
}
|
||||
}
|
||||
|
||||
return groupPossibilities(possibilities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a regular expression string that can be used to find or validate
|
||||
* all variations of this address
|
||||
* @memberof Address6
|
||||
* @instance
|
||||
* @param {string} optionalSubString
|
||||
* @returns {string}
|
||||
*/
|
||||
exports.regularExpressionString = function (optionalSubString) {
|
||||
if (optionalSubString === undefined) {
|
||||
optionalSubString = false;
|
||||
}
|
||||
|
||||
var output = [];
|
||||
|
||||
// TODO: revisit why this is necessary
|
||||
var address6 = new this.constructor(this.correctForm());
|
||||
|
||||
if (address6.elidedGroups === 0) {
|
||||
// The simple case
|
||||
output.push(simpleRegularExpression(address6.parsedAddress));
|
||||
} else if (address6.elidedGroups === v6.GROUPS) {
|
||||
// A completely elided address
|
||||
output.push(possibleElisions(v6.GROUPS));
|
||||
} else {
|
||||
// A partially elided address
|
||||
var halves = address6.address.split('::');
|
||||
|
||||
if (halves[0].length) {
|
||||
output.push(simpleRegularExpression(halves[0].split(':')));
|
||||
}
|
||||
|
||||
output.push(possibleElisions(address6.elidedGroups,
|
||||
halves[0].length !== 0,
|
||||
halves[1].length !== 0));
|
||||
|
||||
if (halves[1].length) {
|
||||
output.push(simpleRegularExpression(halves[1].split(':')));
|
||||
}
|
||||
|
||||
output = [output.join(':')];
|
||||
}
|
||||
|
||||
if (!optionalSubString) {
|
||||
output = [].concat(
|
||||
'(?=^|',
|
||||
ADDRESS_BOUNDARY,
|
||||
'|[^\\w\\:])(', output, ')(?=[^\\w\\:]|',
|
||||
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 {string} optionalSubString
|
||||
* @returns {RegExp}
|
||||
*/
|
||||
exports.regularExpression = function (optionalSubstring) {
|
||||
return new RegExp(this.regularExpressionString(optionalSubstring), 'i');
|
||||
};
|
Reference in New Issue
Block a user