fix #17 only use explicit big-endian methods
This commit is contained in:
parent
fa180b0d4b
commit
0c2184ae00
|
@ -47,7 +47,7 @@ pdns.unpack = function (ab) {
|
||||||
// DO: new Uint8Array(arrayBuffer);
|
// DO: new Uint8Array(arrayBuffer);
|
||||||
// DO NOT: Uint8Array.from(arrayBuffer); // WILL NOT WORK
|
// DO NOT: Uint8Array.from(arrayBuffer); // WILL NOT WORK
|
||||||
|
|
||||||
// DO: new DataView(arrayBuffer).getUint16(7);
|
// DO: new DataView(arrayBuffer).getUint16(7, false);
|
||||||
// DO NOT: arrayBuffer.slice();
|
// DO NOT: arrayBuffer.slice();
|
||||||
//
|
//
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer
|
||||||
|
@ -57,12 +57,12 @@ pdns.unpack = function (ab) {
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
|
||||||
var dv = new DataView(ab);
|
var dv = new DataView(ab);
|
||||||
var id = dv.getUint16(0);
|
var id = dv.getUint16(0, false);
|
||||||
var header = pdns.unpackHeader(dv.getUint16(2));
|
var header = pdns.unpackHeader(dv.getUint16(2, false));
|
||||||
var qdcount = dv.getUint16(4); // query count
|
var qdcount = dv.getUint16(4, false); // query count
|
||||||
var ancount = dv.getUint16(6); // answer count
|
var ancount = dv.getUint16(6, false); // answer count
|
||||||
var nscount = dv.getUint16(8); // authority count
|
var nscount = dv.getUint16(8, false); // authority count
|
||||||
var arcount = dv.getUint16(10); // additional count
|
var arcount = dv.getUint16(10, false); // additional count
|
||||||
var total = 12;
|
var total = 12;
|
||||||
var i;
|
var i;
|
||||||
var rec;
|
var rec;
|
||||||
|
@ -97,9 +97,9 @@ pdns.unpack = function (ab) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
q.type = dv.getUint16(total);
|
q.type = dv.getUint16(total, false);
|
||||||
total += 2;
|
total += 2;
|
||||||
q.class = dv.getUint16(total);
|
q.class = dv.getUint16(total, false);
|
||||||
total += 2;
|
total += 2;
|
||||||
q.byteLength = total - ototal;
|
q.byteLength = total - ototal;
|
||||||
|
|
||||||
|
@ -142,13 +142,13 @@ pdns.unpack = function (ab) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
q.type = dv.getUint16(total);
|
q.type = dv.getUint16(total, false);
|
||||||
total += 2;
|
total += 2;
|
||||||
q.class = dv.getUint16(total);
|
q.class = dv.getUint16(total, false);
|
||||||
total += 2;
|
total += 2;
|
||||||
q.ttl = dv.getUint32(total);
|
q.ttl = dv.getUint32(total, false);
|
||||||
total += 4;
|
total += 4;
|
||||||
q.rdlength = dv.getUint16(total);
|
q.rdlength = dv.getUint16(total, false);
|
||||||
total += 2;
|
total += 2;
|
||||||
|
|
||||||
q.className = classes[q.class];
|
q.className = classes[q.class];
|
||||||
|
@ -157,13 +157,13 @@ pdns.unpack = function (ab) {
|
||||||
|
|
||||||
// TODO actually parse RDATA
|
// TODO actually parse RDATA
|
||||||
q.rdstart = total;
|
q.rdstart = total;
|
||||||
console.log('q.rdata', q.rdata.byteLength, 'bytes:');
|
console.log('q.rdata', q.rdlength, 'bytes:');
|
||||||
console.log(new Uint8Array(ab).slice(total, total + q.rdlength));
|
console.log(new Uint8Array(ab).slice(total, total + q.rdlength));
|
||||||
//q.rdata = Array.prototype.slice.apply(q.rdata);
|
//q.rdata = Array.prototype.slice.apply(q.rdata);
|
||||||
|
|
||||||
total += q.rdlength;
|
|
||||||
//q.rdend = q.rdstart + q.rdlength;
|
//q.rdend = q.rdstart + q.rdlength;
|
||||||
|
|
||||||
|
total += q.rdlength;
|
||||||
q.byteLength = total - ototal;
|
q.byteLength = total - ototal;
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue