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

44 lines
992 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
console.log("what is my record data: " + typeof record.data[0]);
console.log("what are my labels? ");
// var res = record.data[0].split(" ");
// console.log("Res: " + res);
console.log("for each 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;
});
});
console.log("txt rdata length is: " + txtLen);
dv.setUint16(rdLenIndex, txtLen+1, false);
dv.setUint8(rdLenIndex+2, txtLen, false);
// total +=1;
return total;
};
}('undefined' !== typeof window ? window : exports));