fix: flush and class (#28)
This commit is contained in:
parent
84589e7026
commit
600d4acd90
6
index.js
6
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)
|
||||
|
||||
11
test.js
11
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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user