From 28fbc448246617165e350e81949c1a051d247a78 Mon Sep 17 00:00:00 2001 From: westley Date: Sat, 18 Mar 2017 11:40:14 -0600 Subject: [PATCH] wrote the code but dns.rdat.pack.js is having trouble finding the packer for some reason. --- packer/type.txt.js | 49 ++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 26 deletions(-) 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));