Firebase Update

This commit is contained in:
Lukas Nowy
2018-12-22 23:30:39 +01:00
parent befb44764d
commit acffe619b3
11523 changed files with 1614327 additions and 930246 deletions

View File

@ -1,5 +1,5 @@
(function() {
var expandIPv6, ipaddr, ipv4Part, ipv4Regexes, ipv6Part, ipv6Regexes, matchCIDR, root;
var expandIPv6, ipaddr, ipv4Part, ipv4Regexes, ipv6Part, ipv6Regexes, matchCIDR, root, zoneIndex;
ipaddr = {};
@ -43,8 +43,10 @@
}
for (k = 0, len = rangeSubnets.length; k < len; k++) {
subnet = rangeSubnets[k];
if (address.match.apply(address, subnet)) {
return rangeName;
if (address.kind() === subnet[0].kind()) {
if (address.match.apply(address, subnet)) {
return rangeName;
}
}
}
}
@ -74,6 +76,10 @@
return this.octets.join(".");
};
IPv4.prototype.toNormalizedString = function() {
return this.toString();
};
IPv4.prototype.toByteArray = function() {
return this.octets.slice(0);
};
@ -191,7 +197,7 @@
};
ipaddr.IPv6 = (function() {
function IPv6(parts) {
function IPv6(parts, zoneId) {
var i, k, l, len, part, ref;
if (parts.length === 16) {
this.parts = [];
@ -210,6 +216,9 @@
throw new Error("ipaddr: ipv6 part should fit in 16 bits");
}
}
if (zoneId) {
this.zoneId = zoneId;
}
}
IPv6.prototype.kind = function() {
@ -217,56 +226,7 @@
};
IPv6.prototype.toString = function() {
var compactStringParts, k, len, part, pushPart, state, stringParts;
stringParts = (function() {
var k, len, ref, results;
ref = this.parts;
results = [];
for (k = 0, len = ref.length; k < len; k++) {
part = ref[k];
results.push(part.toString(16));
}
return results;
}).call(this);
compactStringParts = [];
pushPart = function(part) {
return compactStringParts.push(part);
};
state = 0;
for (k = 0, len = stringParts.length; k < len; k++) {
part = stringParts[k];
switch (state) {
case 0:
if (part === '0') {
pushPart('');
} else {
pushPart(part);
}
state = 1;
break;
case 1:
if (part === '0') {
state = 2;
} else {
pushPart(part);
}
break;
case 2:
if (part !== '0') {
pushPart('');
pushPart(part);
state = 3;
}
break;
case 3:
pushPart(part);
}
}
if (state === 2) {
pushPart('');
pushPart('');
}
return compactStringParts.join(":");
return this.toNormalizedString().replace(/((^|:)(0(:|$))+)/, '::');
};
IPv6.prototype.toByteArray = function() {
@ -282,8 +242,8 @@
};
IPv6.prototype.toNormalizedString = function() {
var part;
return ((function() {
var addr, part, suffix;
addr = ((function() {
var k, len, ref, results;
ref = this.parts;
results = [];
@ -293,6 +253,11 @@
}
return results;
}).call(this)).join(":");
suffix = '';
if (this.zoneId) {
suffix = '%' + this.zoneId;
}
return addr + suffix;
};
IPv6.prototype.match = function(other, cidrRange) {
@ -337,22 +302,71 @@
return new ipaddr.IPv4([high >> 8, high & 0xff, low >> 8, low & 0xff]);
};
IPv6.prototype.prefixLengthFromSubnetMask = function() {
var cidr, i, k, part, stop, zeros, zerotable;
zerotable = {
0: 16,
32768: 15,
49152: 14,
57344: 13,
61440: 12,
63488: 11,
64512: 10,
65024: 9,
65280: 8,
65408: 7,
65472: 6,
65504: 5,
65520: 4,
65528: 3,
65532: 2,
65534: 1,
65535: 0
};
cidr = 0;
stop = false;
for (i = k = 7; k >= 0; i = k += -1) {
part = this.parts[i];
if (part in zerotable) {
zeros = zerotable[part];
if (stop && zeros !== 0) {
return null;
}
if (zeros !== 16) {
stop = true;
}
cidr += zeros;
} else {
return null;
}
}
return 128 - cidr;
};
return IPv6;
})();
ipv6Part = "(?:[0-9a-f]+::?)+";
zoneIndex = "%[0-9a-z]{1,}";
ipv6Regexes = {
"native": new RegExp("^(::)?(" + ipv6Part + ")?([0-9a-f]+)?(::)?$", 'i'),
transitional: new RegExp(("^((?:" + ipv6Part + ")|(?:::)(?:" + ipv6Part + ")?)") + (ipv4Part + "\\." + ipv4Part + "\\." + ipv4Part + "\\." + ipv4Part + "$"), 'i')
zoneIndex: new RegExp(zoneIndex, 'i'),
"native": new RegExp("^(::)?(" + ipv6Part + ")?([0-9a-f]+)?(::)?(" + zoneIndex + ")?$", 'i'),
transitional: new RegExp(("^((?:" + ipv6Part + ")|(?:::)(?:" + ipv6Part + ")?)") + (ipv4Part + "\\." + ipv4Part + "\\." + ipv4Part + "\\." + ipv4Part) + ("(" + zoneIndex + ")?$"), 'i')
};
expandIPv6 = function(string, parts) {
var colonCount, lastColon, part, replacement, replacementCount;
var colonCount, lastColon, part, replacement, replacementCount, zoneId;
if (string.indexOf('::') !== string.lastIndexOf('::')) {
return null;
}
zoneId = (string.match(ipv6Regexes['zoneIndex']) || [])[0];
if (zoneId) {
zoneId = zoneId.substring(1);
string = string.replace(/%.+$/, '');
}
colonCount = 0;
lastColon = -1;
while ((lastColon = string.indexOf(':', lastColon + 1)) >= 0) {
@ -379,7 +393,7 @@
if (string[string.length - 1] === ':') {
string = string.slice(0, -1);
}
return (function() {
parts = (function() {
var k, len, ref, results;
ref = string.split(":");
results = [];
@ -389,15 +403,20 @@
}
return results;
})();
return {
parts: parts,
zoneId: zoneId
};
};
ipaddr.IPv6.parser = function(string) {
var k, len, match, octet, octets, parts;
if (string.match(ipv6Regexes['native'])) {
var addr, k, len, match, octet, octets, zoneId;
if (ipv6Regexes['native'].test(string)) {
return expandIPv6(string, 8);
} else if (match = string.match(ipv6Regexes['transitional'])) {
parts = expandIPv6(match[1].slice(0, -1), 6);
if (parts) {
zoneId = match[6] || '';
addr = expandIPv6(match[1].slice(0, -1) + zoneId, 6);
if (addr.parts) {
octets = [parseInt(match[2]), parseInt(match[3]), parseInt(match[4]), parseInt(match[5])];
for (k = 0, len = octets.length; k < len; k++) {
octet = octets[k];
@ -405,9 +424,12 @@
return null;
}
}
parts.push(octets[0] << 8 | octets[1]);
parts.push(octets[2] << 8 | octets[3]);
return parts;
addr.parts.push(octets[0] << 8 | octets[1]);
addr.parts.push(octets[2] << 8 | octets[3]);
return {
parts: addr.parts,
zoneId: addr.zoneId
};
}
}
return null;
@ -429,7 +451,7 @@
};
ipaddr.IPv4.isValidFourPartDecimal = function(string) {
if (ipaddr.IPv4.isValid(string) && string.match(/^\d+(\.\d+){3}$/)) {
if (ipaddr.IPv4.isValid(string) && string.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/)) {
return true;
} else {
return false;
@ -437,12 +459,13 @@
};
ipaddr.IPv6.isValid = function(string) {
var e;
var addr, e;
if (typeof string === "string" && string.indexOf(":") === -1) {
return false;
}
try {
new this(this.parser(string));
addr = this.parser(string);
new this(addr.parts, addr.zoneId);
return true;
} catch (error1) {
e = error1;
@ -450,7 +473,7 @@
}
};
ipaddr.IPv4.parse = ipaddr.IPv6.parse = function(string) {
ipaddr.IPv4.parse = function(string) {
var parts;
parts = this.parser(string);
if (parts === null) {
@ -459,44 +482,64 @@
return new this(parts);
};
ipaddr.IPv6.parse = function(string) {
var addr;
addr = this.parser(string);
if (addr.parts === null) {
throw new Error("ipaddr: string is not formatted like ip address");
}
return new this(addr.parts, addr.zoneId);
};
ipaddr.IPv4.parseCIDR = function(string) {
var maskLength, match;
var maskLength, match, parsed;
if (match = string.match(/^(.+)\/(\d+)$/)) {
maskLength = parseInt(match[2]);
if (maskLength >= 0 && maskLength <= 32) {
return [this.parse(match[1]), maskLength];
parsed = [this.parse(match[1]), maskLength];
Object.defineProperty(parsed, 'toString', {
value: function() {
return this.join('/');
}
});
return parsed;
}
}
throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range");
};
ipaddr.IPv4.subnetMaskFromPrefixLength = function(prefix) {
var j, octets;
var filledOctetCount, j, octets;
prefix = parseInt(prefix);
if (prefix < 0 || prefix > 32) {
throw new Error('ipaddr: invalid prefix length');
throw new Error('ipaddr: invalid IPv4 prefix length');
}
octets = Array(4).fill(0);
octets = [0, 0, 0, 0];
j = 0;
while (j < Math.floor(prefix / 8)) {
filledOctetCount = Math.floor(prefix / 8);
while (j < filledOctetCount) {
octets[j] = 255;
j++;
}
octets[Math.floor(prefix / 8)] = Math.pow(2, prefix % 8) - 1 << 8 - (prefix % 8);
return new ipaddr.IPv4(octets);
if (filledOctetCount < 4) {
octets[filledOctetCount] = Math.pow(2, prefix % 8) - 1 << 8 - (prefix % 8);
}
return new this(octets);
};
ipaddr.IPv4.broadcastAddressFromCIDR = function(string) {
var error, i, ipInterface, octets, subnetMask;
var cidr, error, i, ipInterfaceOctets, octets, subnetMaskOctets;
try {
ipInterface = ipaddr.IPv4.parseCIDR(string)[0];
subnetMask = this.subnetMaskFromPrefixLength([ipaddr.IPv4.parseCIDR(string)[1]]);
cidr = this.parseCIDR(string);
ipInterfaceOctets = cidr[0].toByteArray();
subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();
octets = [];
i = 0;
while (i < 4) {
octets.push(parseInt(ipInterface.octets[i], 10) | parseInt(subnetMask.octets[i], 10) ^ 255);
octets.push(parseInt(ipInterfaceOctets[i], 10) | parseInt(subnetMaskOctets[i], 10) ^ 255);
i++;
}
return new ipaddr.IPv4(octets);
return new this(octets);
} catch (error1) {
error = error1;
throw new Error('ipaddr: the address does not have IPv4 CIDR format');
@ -504,17 +547,18 @@
};
ipaddr.IPv4.networkAddressFromCIDR = function(string) {
var error, i, ipInterface, octets, subnetMask;
var cidr, error, i, ipInterfaceOctets, octets, subnetMaskOctets;
try {
ipInterface = ipaddr.IPv4.parseCIDR(string)[0];
subnetMask = this.subnetMaskFromPrefixLength([ipaddr.IPv4.parseCIDR(string)[1]]);
cidr = this.parseCIDR(string);
ipInterfaceOctets = cidr[0].toByteArray();
subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();
octets = [];
i = 0;
while (i < 4) {
octets.push(parseInt(ipInterface.octets[i], 10) & parseInt(subnetMask.octets[i], 10));
octets.push(parseInt(ipInterfaceOctets[i], 10) & parseInt(subnetMaskOctets[i], 10));
i++;
}
return new ipaddr.IPv4(octets);
return new this(octets);
} catch (error1) {
error = error1;
throw new Error('ipaddr: the address does not have IPv4 CIDR format');
@ -522,11 +566,17 @@
};
ipaddr.IPv6.parseCIDR = function(string) {
var maskLength, match;
var maskLength, match, parsed;
if (match = string.match(/^(.+)\/(\d+)$/)) {
maskLength = parseInt(match[2]);
if (maskLength >= 0 && maskLength <= 128) {
return [this.parse(match[1]), maskLength];
parsed = [this.parse(match[1]), maskLength];
Object.defineProperty(parsed, 'toString', {
value: function() {
return this.join('/');
}
});
return parsed;
}
}
throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range");