From 2d590d85d94088bf42bc6380ffbf0bdfdc9e727e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net> Date: Thu, 29 Apr 2021 10:02:29 -0400 Subject: [PATCH] Fix DNS response flag parsing. --- exec/load/dns.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/exec/load/dns.js b/exec/load/dns.js index 060458e5dc..fe725b88f4 100644 --- a/exec/load/dns.js +++ b/exec/load/dns.js @@ -391,17 +391,18 @@ DNS.prototype.handle_response = function(sock) { delete this.outstanding[id]; ret.id = id; - ret.response = !!(ascii(resp[2]) & 1); + ret.response = !!(ascii(resp[2]) & 0x80); if (!ret.response) return null; - ret.opcode = (ascii(resp[2]) & 0x1e) >> 1; + ret.opcode = (ascii(resp[2]) & 0x78) >> 3; if (ret.opcode !== 0 && ret.opcode !== 2) return null; - ret.authoritative = !!(ascii(resp[2]) & (1<<5)); - ret.truncation = !!(ascii(resp[2]) & (1<<6)); - ret.recusrion = !!(ascii(resp[2]) & (1<<7)); - ret.reserved = ascii(resp[3]) & 7; - ret.rcode = ascii(resp[3] & 0xf0) >> 4; + ret.authoritative = !!(ascii(resp[2]) & (1<<2)); + ret.truncation = !!(ascii(resp[2]) & (1<<1)); + ret.recusrion_desired = !!(ascii(resp[2]) & (1)); + ret.recusrion_available = !!(ascii(resp[2]) & (1<<7)); + ret.reserved = (ascii(resp[3]) & 0x70) >> 4; + ret.rcode = ascii(resp[3] & 0x0f); queries = string_to_int16(resp.substr(4, 2)); answers = string_to_int16(resp.substr(6, 2)); -- GitLab