From 676dbabfbc3d150e3c8c8bc637a6431d22e30923 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 21 Jan 2017 03:38:25 -0700 Subject: [PATCH] show id --- pure-parser.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pure-parser.js b/pure-parser.js index b89e54f..8964079 100644 --- a/pure-parser.js +++ b/pure-parser.js @@ -8,7 +8,9 @@ pdns.unpackHeader = function (i) { // i is one element from a Uint16Array (as a 16-bit unsigned integer) var header = { - qr: (i & 0x8000) >> 15 // Query Response (0 is question, 1 is response) + id: 0 // added here to preserve console.log order + + , qr: (i & 0x8000) >> 15 // Query Response (0 is question, 1 is response) , opcode: (i & 0x7800) >> 11 // 0 is question , aa: (i & 0x400) >> 10 // Authoritative Answer (response-only) , tc: (i & 0x200) >> 9 // TrunCated - expect another packet with same (?) id @@ -47,8 +49,7 @@ pdns.unpackQname = function (ui8) { var len; var q = { - byteLength: 0 - , name: '' + name: '' , type: 0 , class: 0 }; @@ -192,6 +193,8 @@ pdns.unpack = function (ab) { answers.push(q); } + header.id = id; + console.log('qdcount', qdcount); header.questions = []; for (i = 0; i < qdcount; i += 1) { @@ -216,5 +219,5 @@ pdns.unpack = function (ab) { unpackAnswer(header.additional); } - console.log('packet', header); + console.log('[packet]', header); };