diff --git a/packer/type.ns.js b/packer/type.ns.js index 70ca723..462d83a 100644 --- a/packer/type.ns.js +++ b/packer/type.ns.js @@ -1,3 +1,5 @@ +// NOTE: this should be EXACTLY the same as PTR + (function (exports) { 'use strict'; @@ -8,8 +10,10 @@ exports.DNS_PACKER_TYPE_NS = function (ab, dv, total, record) { throw new Error("no data on NS record"); } - var rdLenIndex = total; - total +=2; + // RDLENGTH + // leading len and length of string and trailing null (all dots become lengths) + dv.setUint16(total, record.data.length + 2, false); + total += 2; // RDATA // a sequence of labels @@ -23,9 +27,8 @@ exports.DNS_PACKER_TYPE_NS = function (ab, dv, total, record) { total += 1; }); }); - - // RDLENGTH - dv.setUint16(rdLenIndex, record.data.length + 1, false); + dv.setUint8(total, 0x00, false); + total += 1; return total; }; diff --git a/packer/type.ptr.js b/packer/type.ptr.js index 51db54c..96a0a3d 100644 --- a/packer/type.ptr.js +++ b/packer/type.ptr.js @@ -1,35 +1,35 @@ +// NOTE: this should be EXACTLY the same as NS + (function (exports) { 'use strict'; // The host name that represents the supplied UP address -// May be a label, pointer or any combination +// May be a label, pointer or any combination exports.DNS_PACKER_TYPE_PTR = function (ab, dv, total, record) { if (!record.data) { throw new Error("no data for PTR record"); } - var ptrLen = 0; - var rdLenIndex = total; + // RDLENGTH + // leading len and length of string and trailing null (all dots become lengths) + dv.setUint16(total, record.data.length + 2, false); total += 2; - // RDATA + // RDATA // a sequence of labels - record.data.split('.').forEach(function (label){ - console.log("the labels are: " + label); - ptrLen += 1 + label.length; + record.data.split('.').forEach(function (label) { dv.setUint8(total, label.length, false); total += 1; - label.split('').forEach(function (ch){ + label.split('').forEach(function (ch) { dv.setUint8(total, ch.charCodeAt(0), false); total += 1; }); }); - - // RDLENGTH - dv.setUint16(rdLenIndex, record.data.length + 1, false); + dv.setUint8(total, 0x00, false); + total += 1; return total; };