Correctly parses a packet. Yay!

This commit is contained in:
AJ ONeal 2017-01-21 11:13:42 -07:00
parent 3a46d3efda
commit 0dc182772b
1 changed files with 8 additions and 4 deletions

View File

@ -170,9 +170,9 @@ pdns.unpack = function (ab) {
// TODO actually parse RDATA // TODO actually parse RDATA
console.log(ab.byteLength, ab.byteLength - total, ab.byteLength + -total + q.rdlength); console.log(ab.byteLength, ab.byteLength - total, ab.byteLength + -total + q.rdlength);
q.rdata = new Uint8Array(ab).slice(total, 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); console.log(q.rdata);
q.rdata = Array.prototype.slice.apply(q.data);
console.log('total', total); console.log('total', total);
total += q.rdlength; total += q.rdlength;
@ -203,13 +203,17 @@ pdns.unpack = function (ab) {
console.log('nscount', nscount); console.log('nscount', nscount);
header.authority = []; header.authority = [];
for (i = 0; i < nscount; i += 1) { 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); console.log('arcount', arcount);
header.additional = []; header.additional = [];
for (i = 0; i < arcount; i += 1) { 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) { if (ab.byteLength !== total) {