load parsers correctly
This commit is contained in:
parent
113187e68a
commit
55876e2df2
|
@ -22,12 +22,15 @@ exports.DNS_RDATA_PARSE = function (ab, packet, record) {
|
|||
}
|
||||
|
||||
try {
|
||||
parser = exports['DNS_TYPE_' + record.typeName]
|
||||
parser = exports['DNS_PARSER_TYPE_' + record.typeName]
|
||||
|| require('./parser/type.' + record.typeName.toLowerCase())['DNS_PARSER_TYPE_' + record.typeName];
|
||||
}
|
||||
catch (e) { /*console.error(e)*/ }
|
||||
|
||||
if (!parser) {
|
||||
if (require) {
|
||||
require('./parser/type.' + record.typeName.toLowerCase());
|
||||
}
|
||||
throw new Error("Parser for DNS Type " + record.typeName + " could not be loaded."
|
||||
+ " Did you include <script src=\"parser/type." + record.typeName.toLowerCase() + ".js\"></script> ?"
|
||||
+ " (or perhaps we plan to implement it and haven't yet - in which case please open an issue)"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// (meaning text that will be represented as a period-separated
|
||||
// domain name, i.e. www.google.com) then you will need to use
|
||||
// `unpackLabels`, which has compression pointer support
|
||||
var unpackLabels = exports.DNS_UNPACK_LABELS || require('./dns.unpack-labels.js').DNS_UNPACK_LABELS;
|
||||
var unpackLabels = exports.DNS_UNPACK_LABELS || require('../dns.unpack-labels.js').DNS_UNPACK_LABELS;
|
||||
|
||||
// The parser receives exactly 3 parameters as follows:
|
||||
//
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// Canonical name which may lie outside the current zone.
|
||||
// Canonical simply means the expected or real name.
|
||||
|
||||
var unpackLabels = exports.DNS_UNPACK_LABELS || require('./dns.unpack-labels.js').DNS_UNPACK_LABELS;
|
||||
var unpackLabels = exports.DNS_UNPACK_LABELS || require('../dns.unpack-labels.js').DNS_UNPACK_LABELS;
|
||||
exports.DNS_PARSER_TYPE_CNAME = function (ab, packet, record) {
|
||||
record.data = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name;
|
||||
return record;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// May be a label, pointer or any combination
|
||||
|
||||
// ab is arrayBuffer, packet is Object, Record is Object
|
||||
var unpackLabels = exports.DNS_UNPACK_LABELS || require('./dns.unpack-labels.js').DNS_UNPACK_LABELS;
|
||||
var unpackLabels = exports.DNS_UNPACK_LABELS || require('../dns.unpack-labels.js').DNS_UNPACK_LABELS;
|
||||
exports.DNS_PARSER_TYPE_MX = function (ab, packet, record) {
|
||||
|
||||
var rdataAb = ab.slice(record.rdstart, record.rdstart + record.rdlength);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// Comes in variable lengths. It is the name of the primary Master for the Domain.
|
||||
// For example 'ns1.example.com'
|
||||
// It may be a label, pointer or any combination
|
||||
var unpackLabels = exports.DNS_UNPACK_LABELS || require('./dns.unpack-labels.js').DNS_UNPACK_LABELS;
|
||||
var unpackLabels = exports.DNS_UNPACK_LABELS || require('../dns.unpack-labels.js').DNS_UNPACK_LABELS;
|
||||
|
||||
|
||||
exports.DNS_PARSER_TYPE_NS = function (ab , packet, record) {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// ame ttl class rr name
|
||||
// 15 IN PTR www.example.com.
|
||||
|
||||
var unpackLabels = exports.DNS_UNPACK_LABELS || require('./dns.unpack-labels.js').DNS_UNPACK_LABELS;
|
||||
var unpackLabels = exports.DNS_UNPACK_LABELS || require('../dns.unpack-labels.js').DNS_UNPACK_LABELS;
|
||||
exports.DNS_PARSER_TYPE_PTR = function (ab, pack, record) {
|
||||
record.data = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name;
|
||||
return record;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
// SRV identifies the host(s) that will support a particular service. It
|
||||
// is a general purpose RR to discover any service.
|
||||
var unpackLabels = exports.DNS_UNPACK_LABELS || require('./dns.unpack-labels.js').DNS_UNPACK_LABELS;
|
||||
var unpackLabels = exports.DNS_UNPACK_LABELS || require('../dns.unpack-labels.js').DNS_UNPACK_LABELS;
|
||||
|
||||
|
||||
exports.DNS_PARSER_TYPE_SRV = function (ab, packet, record) {
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
// with a host or other name, such as a human readable information about a server
|
||||
// network, data center, and other accounting information.
|
||||
|
||||
var unpackLabels = exports.DNS_UNPACK_LABELS || require('./dns.unpack-labels.js').DNS_UNPACK_LABELS;
|
||||
var unpackLabels = exports.DNS_UNPACK_LABELS || require('../dns.unpack-labels.js').DNS_UNPACK_LABELS;
|
||||
|
||||
exports.DNS_TYPE_TXT = function (ab, packet, record) {
|
||||
exports.DNS_PARSER_TYPE_TXT = function (ab, packet, record) {
|
||||
|
||||
var labels = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' });
|
||||
record.data = [ labels.name ];
|
||||
|
|
Loading…
Reference in New Issue