diff --git a/packer/type.txt.js b/packer/type.txt.js index ee7e0ee..93cfb4f 100644 --- a/packer/type.txt.js +++ b/packer/type.txt.js @@ -4,35 +4,32 @@ // 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"); - // } + if (!record.data){ + throw new Error("no data for TXT record"); + } + + var txtLen = 0; + var rdLenIndex = total; + total += 2; + + // RDATA + + record.data.split('.').forEach(funtion(label){ + txtLen += 1 + label.length; + + dv.setUint8(total, label.length, false); + total += 1; + + label.split('').forEach(function (ch) { + dv.setUint8(total, ch.charCodeAt(0), false); + total += 1; + }); + }); - // console.log("record data is: " + record.data); + dv.setUint16(rdLenIndex, record.data.length + 1, flase);s - // var txtLen = 0; - // var rdLenIndex = total; - // total += 2; - - // //RDATA - // // a sequence of labels - // record.data.split('.').forEach(function (label) { - // txtLen += 1 + label.length; - - // dv.setUint8(total, label.length, false); - // total += 1; - - // label.split('').forEach(function (ch) { - // dv.setUint8(total, ch.charCodeAt(0), false); - // total += 1; - // }); - // }); - - // // RDLENGTH - // dv.setUint16(rdLenIndex, record.data.length + 1, false); - - // return total; + return total; }; }('undefined' !== typeof window ? window : exports));