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

36 lines
726 B
JavaScript

(function (exports) {
'use strict';
// Record type is just any text.
exports.DNS_PACKER_TYPE_TXT = function (ab, dv, total, record) {
if (!record.data){
throw new Error("no data for TXT record");
}
var txtLen = 0;
var rdLenIndex = total;
total += 2;
// RDATA
record.data.split('.').forEach(funtion(label){
txtLen += 1 + label.length;
dv.setUint8(total, label.length, false);
total += 1;
label.split('').forEach(function (ch) {
dv.setUint8(total, ch.charCodeAt(0), false);
total += 1;
});
});
dv.setUint16(rdLenIndex, record.data.length + 1, flase);s
return total;
};
}('undefined' !== typeof window ? window : exports));