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

36 lines
726 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;
total += 2;
2017-03-09 19:34:27 -07:00
// RDATA
2017-03-09 19:34:27 -07:00
record.data.split('.').forEach(funtion(label){
txtLen += 1 + label.length;
2017-03-09 19:34:27 -07:00
dv.setUint8(total, label.length, false);
total += 1;
2017-03-09 19:34:27 -07:00
label.split('').forEach(function (ch) {
dv.setUint8(total, ch.charCodeAt(0), false);
total += 1;
});
});
2017-03-09 19:34:27 -07:00
dv.setUint16(rdLenIndex, record.data.length + 1, flase);s
2017-03-09 19:34:27 -07:00
return total;
2017-03-09 19:34:27 -07:00
};
}('undefined' !== typeof window ? window : exports));