2017-03-10 02:34:27 +00:00
|
|
|
(function (exports) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
// Record type is just any text.
|
|
|
|
|
|
|
|
exports.DNS_PACKER_TYPE_TXT = function (ab, dv, total, record) {
|
2017-03-18 17:40:14 +00:00
|
|
|
if (!record.data){
|
|
|
|
throw new Error("no data for TXT record");
|
|
|
|
}
|
2017-03-10 02:34:27 +00:00
|
|
|
|
2017-03-18 17:40:14 +00:00
|
|
|
var txtLen = 0;
|
|
|
|
var rdLenIndex = total;
|
2017-03-23 23:33:55 +00:00
|
|
|
total += 3;
|
2017-03-10 02:34:27 +00:00
|
|
|
|
2017-03-18 17:40:14 +00:00
|
|
|
// RDATA
|
2017-03-23 23:33:55 +00:00
|
|
|
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);
|
2017-03-10 02:34:27 +00:00
|
|
|
|
2017-03-23 23:33:55 +00:00
|
|
|
console.log("for each rdata");
|
|
|
|
record.data.forEach(function(str){
|
2017-03-10 02:34:27 +00:00
|
|
|
|
2017-03-23 23:33:55 +00:00
|
|
|
str.split('').forEach(function(ch){
|
2017-03-10 02:34:27 +00:00
|
|
|
|
2017-03-23 23:33:55 +00:00
|
|
|
|
|
|
|
txtLen += 1;
|
|
|
|
// console.log(chcim);
|
|
|
|
dv.setUint8(total, ch.charCodeAt(0), false);
|
|
|
|
total += 1;
|
|
|
|
|
2017-03-18 17:40:14 +00:00
|
|
|
});
|
|
|
|
});
|
2017-03-10 02:34:27 +00:00
|
|
|
|
2017-03-23 23:33:55 +00:00
|
|
|
console.log("txt rdata length is: " + txtLen);
|
|
|
|
dv.setUint16(rdLenIndex, txtLen+1, false);
|
|
|
|
dv.setUint8(rdLenIndex+2, txtLen, false);
|
|
|
|
// total +=1;
|
2017-03-10 02:34:27 +00:00
|
|
|
|
2017-03-18 17:40:14 +00:00
|
|
|
return total;
|
2017-03-10 02:34:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}('undefined' !== typeof window ? window : exports));
|