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

36 lines
703 B
JavaScript
Raw Normal View History

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) {
if (!record.data){
throw new Error("no data for TXT record");
}
2017-03-10 02:34:27 +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
// RDATA
2017-03-23 23:33:55 +00:00
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-09-25 21:57:40 +00:00
});
});
2017-03-10 02:34:27 +00:00
2017-03-23 23:33:55 +00:00
dv.setUint16(rdLenIndex, txtLen+1, false);
dv.setUint8(rdLenIndex+2, txtLen, false);
// total +=1;
2017-03-10 02:34:27 +00:00
return total;
2017-03-10 02:34:27 +00:00
};
}('undefined' !== typeof window ? window : exports));