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

36 lines
703 B
JavaScript
Raw Normal View History

2017-03-09 19:34:27 -07:00
(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");
}
2017-03-09 19:34:27 -07:00
var txtLen = 0;
var rdLenIndex = total;
2017-03-23 17:33:55 -06:00
total += 3;
2017-03-09 19:34:27 -07:00
// RDATA
2017-03-23 17:33:55 -06:00
record.data.forEach(function(str){
2017-03-09 19:34:27 -07:00
2017-03-23 17:33:55 -06:00
str.split('').forEach(function(ch){
2017-03-09 19:34:27 -07:00
2017-03-23 17:33:55 -06:00
txtLen += 1;
// console.log(chcim);
dv.setUint8(total, ch.charCodeAt(0), false);
total += 1;
2017-09-25 15:57:40 -06:00
});
});
2017-03-09 19:34:27 -07:00
2017-03-23 17:33:55 -06:00
dv.setUint16(rdLenIndex, txtLen+1, false);
dv.setUint8(rdLenIndex+2, txtLen, false);
// total +=1;
2017-03-09 19:34:27 -07:00
return total;
2017-03-09 19:34:27 -07:00
};
}('undefined' !== typeof window ? window : exports));