bug #4 add cp support
This commit is contained in:
parent
5e1fff748e
commit
736ea21b54
|
@ -42,6 +42,10 @@ pdns.unpackQname = function (ab, ptr, q) {
|
|||
, cpcount: 0
|
||||
};
|
||||
|
||||
if (q.cpcount > 25) {
|
||||
throw new Error("compression pointer loop detected (over 25 pointers seems like a loop)");
|
||||
}
|
||||
|
||||
do {
|
||||
label.length = 0;
|
||||
len = ui8[total];
|
||||
|
@ -53,6 +57,12 @@ pdns.unpackQname = function (ab, ptr, q) {
|
|||
console.log('ptr to', cpptr);
|
||||
console.log('label len', cplen);
|
||||
console.log('label', Buffer.from(ui8.slice(cpptr + 1, cpptr + 1 + cplen)).toString('ascii'));
|
||||
|
||||
// we're not coming back!
|
||||
ptr = cpptr;
|
||||
q.cpcount += 1;
|
||||
q.byteLength += 2; // cp and len
|
||||
return pdns.unpackQname(ab, ptr, q);
|
||||
throw new Error("discovered a compression pointer at byte " + total
|
||||
+ " pointing to byte " + ui8[total + 1]
|
||||
+ ", but compression pointer support is not yet implemented"
|
||||
|
@ -127,6 +137,8 @@ pdns.unpack = function (ab) {
|
|||
var ototal = total;
|
||||
var data = new Uint8Array(ab).slice(total);
|
||||
var q = pdns.unpackQname(ab, total);
|
||||
console.log('unpackQuestion:');
|
||||
console.log(q);
|
||||
total += q.byteLength;
|
||||
|
||||
if (ab.byteLength - total < 4) {
|
||||
|
@ -149,6 +161,8 @@ pdns.unpack = function (ab) {
|
|||
var ototal = total;
|
||||
var data = new Uint8Array(ab).slice(total);
|
||||
var q = pdns.unpackQname(ab, total);
|
||||
console.log('unpackAnswer:');
|
||||
console.log(q);
|
||||
total += q.byteLength;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue