This commit is contained in:
AJ ONeal 2017-01-21 03:38:25 -07:00
parent 3bbada69aa
commit 676dbabfbc
1 changed files with 7 additions and 4 deletions

View File

@ -8,7 +8,9 @@ pdns.unpackHeader = function (i) {
// i is one element from a Uint16Array (as a 16-bit unsigned integer) // i is one element from a Uint16Array (as a 16-bit unsigned integer)
var header = { 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 , opcode: (i & 0x7800) >> 11 // 0 is question
, aa: (i & 0x400) >> 10 // Authoritative Answer (response-only) , aa: (i & 0x400) >> 10 // Authoritative Answer (response-only)
, tc: (i & 0x200) >> 9 // TrunCated - expect another packet with same (?) id , tc: (i & 0x200) >> 9 // TrunCated - expect another packet with same (?) id
@ -47,8 +49,7 @@ pdns.unpackQname = function (ui8) {
var len; var len;
var q = { var q = {
byteLength: 0 name: ''
, name: ''
, type: 0 , type: 0
, class: 0 , class: 0
}; };
@ -192,6 +193,8 @@ pdns.unpack = function (ab) {
answers.push(q); answers.push(q);
} }
header.id = id;
console.log('qdcount', qdcount); console.log('qdcount', qdcount);
header.questions = []; header.questions = [];
for (i = 0; i < qdcount; i += 1) { for (i = 0; i < qdcount; i += 1) {
@ -216,5 +219,5 @@ pdns.unpack = function (ab) {
unpackAnswer(header.additional); unpackAnswer(header.additional);
} }
console.log('packet', header); console.log('[packet]', header);
}; };