From e4d9dbb55853ae5e5a2cca5f0514db2a2f5665e5 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 25 Jan 2023 09:57:07 +0100 Subject: [PATCH] dns: resolve cname records using unbound cname record can be external and the original NS may not respond to recursive queries --- src/dns/waitfordns.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/dns/waitfordns.js b/src/dns/waitfordns.js index 582d26e92..8d3a1204c 100644 --- a/src/dns/waitfordns.js +++ b/src/dns/waitfordns.js @@ -7,7 +7,8 @@ const assert = require('assert'), debug = require('debug')('box:dns/waitfordns'), dig = require('../dig.js'), promiseRetry = require('../promise-retry.js'), - safe = require('safetydance'); + safe = require('safetydance'), + _ = require('underscore'); async function resolveIp(hostname, type, options) { assert.strictEqual(typeof hostname, 'string'); @@ -20,12 +21,12 @@ async function resolveIp(hostname, type, options) { if (!error && results.length !== 0) return results; // try CNAME record at authoritative server - debug(`resolveIp: Checking if ${hostname} has CNAME record at ${options.server}`); + debug(`resolveIp: No A record. Checking if ${hostname} has CNAME record at ${options.server}`); const cnameResults = await dig.resolve(hostname, 'CNAME', options); if (cnameResults.length === 0) return cnameResults; // recurse lookup the CNAME record - debug(`resolveIp: Resolving ${hostname}'s CNAME record ${cnameResults[0]}`); + debug(`resolveIp: CNAME record found. Resolving ${hostname}'s CNAME record ${cnameResults[0]} using unbound`); return await dig.resolve(cnameResults[0], type, options); }