2017-01-21 21:33:51 +00:00
|
|
|
(function (exports) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var classes = exports.DNS_CLASSES || require('./dns.classes.js').DNS_CLASSES;
|
|
|
|
var types = exports.DNS_TYPES || require('./dns.types.js').DNS_TYPES;
|
|
|
|
|
|
|
|
exports.DNS_RDATA_PARSE = function (ab, packet, record) {
|
|
|
|
// ab is needed if the rdata makes use of compression pointers
|
|
|
|
// packet is given for convenience
|
|
|
|
var parser;
|
|
|
|
|
2017-01-27 00:03:16 +00:00
|
|
|
|
2017-01-21 21:33:51 +00:00
|
|
|
if (!record.className) {
|
|
|
|
throw new Error("Support for DNS Class " + record.class.toString(16) + "(" + record.class + ")"
|
|
|
|
+ " is not implemented yet. Open an issue if you actually need support"
|
|
|
|
+ " (i.e. you're not working with a malformed packet)"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!record.typeName) {
|
|
|
|
throw new Error("Support for DNS Type " + record.type.toString(16) + "(" + record.type + ")"
|
|
|
|
+ " is not implemented yet. Open an issue if you actually need support"
|
|
|
|
+ " (i.e. you're not working with a malformed packet)"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
parser = exports['DNS_TYPE_' + record.typeName]
|
2017-01-21 21:39:26 +00:00
|
|
|
|| require('./dns.type.' + record.typeName.toLowerCase())['DNS_TYPE_' + record.typeName];
|
2017-01-21 21:33:51 +00:00
|
|
|
}
|
|
|
|
catch (e) { /*console.error(e)*/ }
|
|
|
|
|
|
|
|
if (!parser) {
|
|
|
|
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> ?"
|
|
|
|
+ " (or perhaps we plan to implement it and haven't yet - in which case please open an issue)"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-02-03 01:39:32 +00:00
|
|
|
// NOTE: record will be modified
|
|
|
|
// Things that get added include:
|
|
|
|
// address, data, priority exchange, weight,
|
2017-01-21 21:33:51 +00:00
|
|
|
return parser(ab, packet, record);
|
|
|
|
};
|
|
|
|
|
|
|
|
}('undefined' !== typeof window ? window : exports));
|