From fa180b0d4b57a788015ff61c21b484a1631ea7c4 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 30 Jan 2017 11:28:05 -0700 Subject: [PATCH] use ab.slice(start, end) instead of ui8 array for rdata --- dns.type.a.js | 2 +- pure-parser.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dns.type.a.js b/dns.type.a.js index 0d70dd2..f1dd471 100644 --- a/dns.type.a.js +++ b/dns.type.a.js @@ -4,7 +4,7 @@ // An 'A' record is a 32-bit value representing the IP address exports.DNS_TYPE_A = function (ab, packet, record) { - var ui8 = record.rdata; + var ui8 = new Uint8Array(ab.slice(record.rdstart, record.rdstart + record.rdlength)); // i.e. 127.0.0.1 return ui8[0] + '.' + ui8[1] + '.' + ui8[2] + '.' + ui8[3]; diff --git a/pure-parser.js b/pure-parser.js index 2cdff6a..c798e9e 100644 --- a/pure-parser.js +++ b/pure-parser.js @@ -125,7 +125,7 @@ pdns.unpack = function (ab) { , cpcount: 0 , rdstart: 0 - , rdata: 0 + //, rdata: 0 , rdlength: 0 }); //console.log('unpackAnswer QNAME:'); @@ -157,12 +157,12 @@ pdns.unpack = function (ab) { // TODO actually parse RDATA q.rdstart = total; - q.rdata = new Uint8Array(ab).slice(total, total + q.rdlength); console.log('q.rdata', q.rdata.byteLength, 'bytes:'); - console.log(q.rdata); + console.log(new Uint8Array(ab).slice(total, total + q.rdlength)); //q.rdata = Array.prototype.slice.apply(q.rdata); total += q.rdlength; + //q.rdend = q.rdstart + q.rdlength; q.byteLength = total - ototal; return q;