1
0
Fork 0

added shortening of unpacked string IPv6 addresses

Esse commit está contido em:
tigerbot 2017-05-22 18:22:54 -06:00
commit f8cf8aef77
1 arquivos alterados com 14 adições e 0 exclusões

Ver arquivo

@ -27,6 +27,20 @@ exports.DNS_PARSER_TYPE_AAAA = function (ab, packet, record) {
s += dv.getUint16(i, false).toString(16);
}
// Represent the string address as recommended on the wikipedia page
// https://en.wikipedia.org/wiki/IPv6_address#Recommended_representation_as_text.
// (shorten the longest section of 0's as long as it's more than one section, replacing
// the left-most instance in the event of ties.)
var re = /:(0:)+/g;
var match;
var longest = '_BAD';
while (!!(match = re.exec(s))) {
if (match[0].length > longest.length) {
longest = match[0];
}
}
s = s.replace(longest, '::');
record.address = s;
return record;
};