diff --git a/lib/dns.js b/lib/dns.js index 351fa43f357..97793eb12aa 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -439,8 +439,6 @@ ObjectDefineProperties(module.exports, { get() { if (promises === null) { promises = require('internal/dns/promises'); - promises.setServers = defaultResolverSetServers; - promises.setDefaultResultOrder = setDefaultResultOrder; } return promises; } diff --git a/lib/dns/promises.js b/lib/dns/promises.js index ad8a2561ef5..35881e5bb47 100644 --- a/lib/dns/promises.js +++ b/lib/dns/promises.js @@ -1,5 +1,3 @@ 'use strict'; -const dnsPromises = require('internal/dns/promises'); -dnsPromises.setServers = require('dns').setServers; -module.exports = dnsPromises; +module.exports = require('internal/dns/promises'); diff --git a/lib/internal/dns/promises.js b/lib/internal/dns/promises.js index 395b059758f..334260923fa 100644 --- a/lib/internal/dns/promises.js +++ b/lib/internal/dns/promises.js @@ -17,6 +17,8 @@ const { emitInvalidHostnameWarning, getDefaultVerbatim, errorCodes: dnsErrorCodes, + setDefaultResultOrder, + setDefaultResolver, } = require('internal/dns/utils'); const { NODATA, @@ -349,11 +351,20 @@ Resolver.prototype.resolve = function resolve(hostname, rrtype) { return ReflectApply(resolver, this, [hostname]); }; +function defaultResolverSetServers(servers) { + const resolver = new Resolver(); + + resolver.setServers(servers); + setDefaultResolver(resolver); + bindDefaultResolver(module.exports, Resolver.prototype); +} module.exports = { lookup, lookupService, Resolver, + setDefaultResultOrder, + setServers: defaultResolverSetServers, // ERROR CODES NODATA,