From 600d4acd90207c20fd5c358fe9531cbe7314d005 Mon Sep 17 00:00:00 2001 From: Richard Schneider Date: Mon, 5 Feb 2018 07:59:47 +1300 Subject: [PATCH] fix: flush and class (#28) --- index.js | 6 +++--- test.js | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 11c4640..94e9ae9 100644 --- a/index.js +++ b/index.js @@ -680,11 +680,11 @@ answer.decode = function (buf, offset) { a.name = name.decode(buf, offset) offset += name.decode.bytes a.type = types.toString(buf.readUInt16BE(offset)) - a.class = classes.toString(buf.readUInt16BE(offset + 2)) + const klass = buf.readUInt16BE(offset + 2) a.ttl = buf.readUInt32BE(offset + 4) - a.flush = !!(a.class & FLUSH_MASK) - if (a.flush) a.class &= NOT_FLUSH_MASK + a.class = classes.toString(klass & NOT_FLUSH_MASK) + a.flush = !!(klass & FLUSH_MASK) const enc = renc(a.type) a.data = enc.decode(buf, offset + 8) diff --git a/test.js b/test.js index 977234e..9813de8 100644 --- a/test.js +++ b/test.js @@ -153,6 +153,17 @@ tape('query', function (t) { }) tape('response', function (t) { + testEncoder(t, packet, { + type: 'response', + answers: [{ + type: 'A', + class: 'IN', + flush: true, + name: 'hello.a.com', + data: '127.0.0.1' + }] + }) + testEncoder(t, packet, { type: 'response', flags: packet.TRUNCATED_RESPONSE,