bug #4 add cp support

This commit is contained in:
AJ ONeal 2017-01-25 14:47:14 -07:00
父節點 5e1fff748e
當前提交 736ea21b54
共有 1 個文件被更改,包括 14 次插入0 次删除

查看文件

@ -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;