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

36 lines
703 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 += 3;
// RDATA
record.data.forEach(function(str){
str.split('').forEach(function(ch){
txtLen += 1;
// console.log(chcim);
dv.setUint8(total, ch.charCodeAt(0), false);
total += 1;
});
});
dv.setUint16(rdLenIndex, txtLen+1, false);
dv.setUint8(rdLenIndex+2, txtLen, false);
// total +=1;
return total;
};
}('undefined' !== typeof window ? window : exports));