dns-suite.js/packer/type.ns.js

34 lines
737 B
JavaScript
Raw Normal View History

2017-03-09 00:53:15 +00:00
(function (exports) {
'use strict';
// NS name for the supplied domain. May be label, pointer or any combination
exports.DNS_PACKER_TYPE_NS = function (ab, dv, total, record) {
2017-10-07 01:27:37 +00:00
if (!record.data) {
2017-03-09 00:53:15 +00:00
throw new Error("no data on NS record");
}
var rdLenIndex = total;
total +=2;
2017-10-07 01:27:37 +00:00
// RDATA
2017-03-09 00:53:15 +00:00
// a sequence of labels
2017-10-07 01:27:37 +00:00
record.data.split('.').forEach(function (label) {
2017-03-09 00:53:15 +00:00
dv.setUint8(total, label.length, false);
total += 1;
2017-10-07 01:27:37 +00:00
label.split('').forEach(function (ch) {
2017-03-09 00:53:15 +00:00
dv.setUint8(total, ch.charCodeAt(0), false);
total += 1;
});
});
// RDLENGTH
dv.setUint16(rdLenIndex, record.data.length + 1, false);
return total;
};
}('undefined' !== typeof window ? window : exports));