From 0dc182772ba9f9c63be072b2900a03d0785aa683 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 21 Jan 2017 11:13:42 -0700 Subject: [PATCH] Correctly parses a packet. Yay! --- pure-parser.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pure-parser.js b/pure-parser.js index 8158065..ddf696b 100644 --- a/pure-parser.js +++ b/pure-parser.js @@ -170,9 +170,9 @@ pdns.unpack = function (ab) { // TODO actually parse RDATA console.log(ab.byteLength, ab.byteLength - total, ab.byteLength + -total + q.rdlength); q.rdata = new Uint8Array(ab).slice(total, total + q.rdlength); - console.log('q.rdata', q.rdata.byteLength); + console.log('q.rdata', q.rdata.byteLength, 'bytes:'); + q.rdata = Array.prototype.slice.apply(q.rdata); console.log(q.rdata); - q.rdata = Array.prototype.slice.apply(q.data); console.log('total', total); total += q.rdlength; @@ -203,13 +203,17 @@ pdns.unpack = function (ab) { console.log('nscount', nscount); header.authority = []; for (i = 0; i < nscount; i += 1) { - unpackAnswer(header.authority); + rec = unpackAnswer(ab, dv, total); + total += rec.qtotal; + header.authority.push(rec); } console.log('arcount', arcount); header.additional = []; for (i = 0; i < arcount; i += 1) { - unpackAnswer(header.additional); + rec = unpackAnswer(ab, dv, total); + total += rec.qtotal; + header.additional.push(rec); } if (ab.byteLength !== total) {