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 Packer = (exports.DNS_PACKER || require('./dns.packer.js').DNS_PACKER);
//var classes = exports.DNS_CLASSES || require('./dns.classes.js').DNS_CLASSES; //var classes = exports.DNS_CLASSES || require('./dns.classes.js').DNS_CLASSES;
//var types = exports.DNS_TYPES || require('./dns.types.js').DNS_TYPES; //var types = exports.DNS_TYPES || require('./dns.types.js').DNS_TYPES;
var logged = {};
exports.DNSPacket = { exports.DNSPacket = {
parse: function (nb) { parse: function (nb) {
// backwards compat with node buffer // backwards compat with node buffer
@ -21,8 +23,14 @@ exports.DNSPacket = {
record = Parser.unpackRdata(ab, packet, record); record = Parser.unpackRdata(ab, packet, record);
} catch (e) { } catch (e) {
console.error('[Error] unpackRdata: ' + e.message);
record.error = e; 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; pdns._unpackLabels = exports.DNS_UNPACK_LABELS || require('./dns.unpack-labels.js').DNS_UNPACK_LABELS;
var optWarned = false;
pdns.unpackOpt = function (ab, packet, rec) { pdns.unpackOpt = function (ab, packet, rec) {
var dv; var dv;
// https://tools.ietf.org/html/rfc6891#section-6 // 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) { 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) { if (packet.name) {
console.warn("name '" + packet.name + "' should not exist for type OPT 0x29 41"); console.warn("name '" + packet.name + "' should not exist for type OPT 0x29 41");
@ -60,11 +64,11 @@ pdns.unpackOpt = function (ab, packet, rec) {
packet.edns_version = dv.getUint8(1, false); packet.edns_version = dv.getUint8(1, false);
packet.do = dv.getUint8(2, false) & 0x8000; // 1000 0000 packet.do = dv.getUint8(2, false) & 0x8000; // 1000 0000
packet.z = dv.getUint16(2, false) & 0x7FFF; // 0111 1111 packet.z = dv.getUint16(2, false) & 0x7FFF; // 0111 1111
/* /*
"edns_options": [], "edns_options": [],
"payload": 4096, "payload": 4096,
"edns_version": 0, "edns_version": 0,
"do": 0 "do": 0
*/ */
}; };
pdns.unpack = function (ab) { pdns.unpack = function (ab) {