From caedd72fbeb8b389e9d47b4ad33a56d2954d9114 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 29 Mar 2019 20:10:57 -0700 Subject: [PATCH 1/2] dns: refactor lib/internal/dns/utils.js * alphabetize contenst of `resolverKeys` array * less line-wrapping for increased code clarity --- lib/internal/dns/utils.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/internal/dns/utils.js b/lib/internal/dns/utils.js index d279a58840154e..70097663546a1a 100644 --- a/lib/internal/dns/utils.js +++ b/lib/internal/dns/utils.js @@ -65,8 +65,7 @@ class Resolver { if (ipVersion !== 0) { const port = - parseInt(serv.replace(addrSplitRE, '$2')) || - IANA_DNS_PORT; + parseInt(serv.replace(addrSplitRE, '$2')) || IANA_DNS_PORT; return newSet.push([ipVersion, match[1], port]); } } @@ -103,18 +102,18 @@ let defaultResolver = new Resolver(); const resolverKeys = [ 'getServers', 'resolve', - 'resolveAny', 'resolve4', 'resolve6', + 'resolveAny', 'resolveCname', 'resolveMx', + 'resolveNaptr', 'resolveNs', - 'resolveTxt', - 'resolveSrv', 'resolvePtr', - 'resolveNaptr', 'resolveSoa', - 'reverse' + 'resolveSrv', + 'resolveTxt', + 'reverse', ]; function getDefaultResolver() { From 2e4719fcba5c24c02214657c4e339053a046535b Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 29 Mar 2019 21:31:23 -0700 Subject: [PATCH 2/2] test: add IPv6 brackets but no port to test-dns Add a test case to test-dns to check that supply an IPv6 host with brackets but no explicit port to `dns.setServers()` yields expected results. This is the final bit of test coverage missing for lib/internal/dns/utils.js. --- test/parallel/test-dns.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-dns.js b/test/parallel/test-dns.js index f974c2afa62862..40e0e605cda36a 100644 --- a/test/parallel/test-dns.js +++ b/test/parallel/test-dns.js @@ -121,13 +121,15 @@ const ports = [ '4.4.4.4:53', '[2001:4860:4860::8888]:53', '103.238.225.181:666', - '[fe80::483a:5aff:fee6:1f04]:666' + '[fe80::483a:5aff:fee6:1f04]:666', + '[fe80::483a:5aff:fee6:1f04]', ]; const portsExpected = [ '4.4.4.4', '2001:4860:4860::8888', '103.238.225.181:666', - '[fe80::483a:5aff:fee6:1f04]:666' + '[fe80::483a:5aff:fee6:1f04]:666', + 'fe80::483a:5aff:fee6:1f04', ]; dns.setServers(ports); assert.deepStrictEqual(dns.getServers(), portsExpected);