From 12038465f66061970a6659f4c0f26c0a0ace56be Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 15 Dec 2017 02:25:23 -0700 Subject: [PATCH] allow empty string in query --- dns.packer.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dns.packer.js b/dns.packer.js index 61f876a..bba95f0 100644 --- a/dns.packer.js +++ b/dns.packer.js @@ -29,7 +29,7 @@ var dnspack = exports.DNS_PACKER = { dv.setUint16(10, (packet.additional||[]).length + (packet.payload ? 1 : 0), false); function lint(r) { - if (!r.name) { + if (!r.name && 'string' !== typeof r.name) { throw new Error("missing name"); } @@ -70,7 +70,8 @@ var dnspack = exports.DNS_PACKER = { labelsMap[total] = { total: total, name: sequence }; labelsMap[sequence] = labelsMap[total]; } - sequence.split('.').forEach(function (label) { + // allow 0-length string for TLD root NS queries + (sequence && sequence.split('.') || []).forEach(function (label) { dv.setUint8(total, label.length, false); total += 1;