creater parser directory

This commit is contained in:
AJ ONeal 2017-02-17 16:13:57 -07:00
parent 72fece4124
commit a26fef5e33
11 changed files with 14 additions and 14 deletions

View File

@ -23,13 +23,13 @@ exports.DNS_RDATA_PARSE = function (ab, packet, record) {
try { try {
parser = exports['DNS_TYPE_' + record.typeName] parser = exports['DNS_TYPE_' + record.typeName]
|| require('./dns.type.' + record.typeName.toLowerCase())['DNS_TYPE_' + record.typeName]; || require('./parser/type.' + record.typeName.toLowerCase())['DNS_PARSER_TYPE_' + record.typeName];
} }
catch (e) { /*console.error(e)*/ } catch (e) { /*console.error(e)*/ }
if (!parser) { if (!parser) {
throw new Error("Parser for DNS Type " + record.typeName + " could not be loaded." throw new Error("Parser for DNS Type " + record.typeName + " could not be loaded."
+ " Did you include <script src=\"dns.type." + record.typeName.toLowerCase() + ".js\"></script> ?" + " 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)" + " (or perhaps we plan to implement it and haven't yet - in which case please open an issue)"
); );
} }

View File

@ -30,7 +30,7 @@ var unpackLabels = exports.DNS_UNPACK_LABELS || require('./dns.unpack-labels.js'
// signifying the type at which the binary segment for this record // signifying the type at which the binary segment for this record
// begins and its length // begins and its length
// //
exports.DNS_TYPE_MX = function (ab, packet, record) { exports.DNS_PARSER_TYPE_MX = function (ab, packet, record) {
// //
// Slicing RData // Slicing RData
// //

View File

@ -3,7 +3,7 @@
// An 'A' record is a 32-bit value representing the IP address // An 'A' record is a 32-bit value representing the IP address
exports.DNS_TYPE_A = function (ab, packet, record) { exports.DNS_PARSER_TYPE_A = function (ab, packet, record) {
var ui8 = new Uint8Array(ab.slice(record.rdstart, record.rdstart + record.rdlength)); var ui8 = new Uint8Array(ab.slice(record.rdstart, record.rdstart + record.rdlength));
// i.e. 127.0.0.1 // i.e. 127.0.0.1
record.address = ui8[0] + '.' + ui8[1] + '.' + ui8[2] + '.' + ui8[3]; record.address = ui8[0] + '.' + ui8[1] + '.' + ui8[2] + '.' + ui8[3];

View File

@ -4,7 +4,7 @@
// Value: IP Address // Value: IP Address
// Meaning:Use: 16 octets represting the IP address // Meaning:Use: 16 octets represting the IP address
exports.DNS_TYPE_AAAA = function (ab, packet, record) { exports.DNS_PARSER_TYPE_AAAA = function (ab, packet, record) {
var rdataAb = ab.slice(record.rdstart, record.rdstart + record.rdlength); var rdataAb = ab.slice(record.rdstart, record.rdstart + record.rdlength);
// We can't use Uint16Array because it doesn't specify Endianness // We can't use Uint16Array because it doesn't specify Endianness

View File

@ -6,7 +6,7 @@
// Canonical simply means the expected or real name. // 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_TYPE_CNAME = function (ab, packet, record) { exports.DNS_PARSER_TYPE_CNAME = function (ab, packet, record) {
record.data = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name; record.data = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name;
return record; return record;
}; };

View File

@ -10,7 +10,7 @@
// ab is arrayBuffer, packet is Object, Record is Object // 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_TYPE_MX = function (ab, packet, record) { exports.DNS_PARSER_TYPE_MX = function (ab, packet, record) {
var rdataAb = ab.slice(record.rdstart, record.rdstart + record.rdlength); var rdataAb = ab.slice(record.rdstart, record.rdstart + record.rdlength);
var dv = new DataView(rdataAb); var dv = new DataView(rdataAb);

View File

@ -7,7 +7,7 @@
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_NS = function (ab , packet, record) { exports.DNS_PARSER_TYPE_NS = function (ab , packet, record) {
record.data = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name; record.data = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name;
return record; return record;

View File

@ -10,7 +10,7 @@
// 15 IN PTR www.example.com. // 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_TYPE_PTR = function (ab, pack, record) { exports.DNS_PARSER_TYPE_PTR = function (ab, pack, record) {
record.data = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name; record.data = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name;
return record; return record;
}; };

View File

@ -14,7 +14,7 @@
// Minimum TTL Unsigned 32-bit integer // Minimum TTL Unsigned 32-bit integer
exports.DNS_TYPE_SOA = function (ab, packet, record) { exports.DNS_PARSER_TYPE_SOA = function (ab, packet, record) {
}; };

View File

@ -7,7 +7,7 @@
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_SRV = function (ab, packet, record) { exports.DNS_PARSER_TYPE_SRV = function (ab, packet, record) {
var rdataAb = ab.slice(record.rdstart,record.rdstart + record.rdlength) var rdataAb = ab.slice(record.rdstart,record.rdstart + record.rdlength)
var dv = new DataView(rdataAb); var dv = new DataView(rdataAb);