limited how often we log about unsupported features

This commit is contained in:
tigerbot 2017-05-23 15:58:32 -06:00
parent f8cf8aef77
commit a137d6b937
2 changed files with 20 additions and 8 deletions

10
dns.js
View File

@ -5,6 +5,8 @@ var Parser = (exports.DNS_PARSER || require('./dns.parser.js').DNS_PARSER);
var Packer = (exports.DNS_PACKER || require('./dns.packer.js').DNS_PACKER);
//var classes = exports.DNS_CLASSES || require('./dns.classes.js').DNS_CLASSES;
//var types = exports.DNS_TYPES || require('./dns.types.js').DNS_TYPES;
var logged = {};
exports.DNSPacket = {
parse: function (nb) {
// backwards compat with node buffer
@ -21,8 +23,14 @@ exports.DNSPacket = {
record = Parser.unpackRdata(ab, packet, record);
} catch (e) {
console.error('[Error] unpackRdata: ' + e.message);
record.error = e;
if (!/^support for dns/i.test(e.message)) {
console.error('[Error] unpackRdata: ' + e.message);
}
else if (!logged[e.message]) {
console.error('[Error] unpackRdata: ' + e.message);
logged[e.message] = true;
}
}
}

View File

@ -31,13 +31,17 @@ pdns.unpackHeader = function (i) {
pdns._unpackLabels = exports.DNS_UNPACK_LABELS || require('./dns.unpack-labels.js').DNS_UNPACK_LABELS;
var optWarned = false;
pdns.unpackOpt = function (ab, packet, rec) {
var dv;
// https://tools.ietf.org/html/rfc6891#section-6
console.log('OPT is not yet supported');
if (!optWarned) {
console.warn('OPT is not yet supported');
optWarned = true;
}
if ('undefined' !== typeof packet.edns_version) {
console.warn("More that one OPT, should respond with FORMERR, but not implmentede");
console.warn("More that one OPT, should respond with FORMERR, but not implemented");
}
if (packet.name) {
console.warn("name '" + packet.name + "' should not exist for type OPT 0x29 41");