diff --git a/lib/dns.js b/lib/dns.js index af5416c62478cc..02e007b54ec26b 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -386,8 +386,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 ad8a2561ef51e4..35881e5bb47374 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 9625e9e7b9b6ea..4e4e385f2eb758 100644 --- a/lib/internal/dns/promises.js +++ b/lib/internal/dns/promises.js @@ -16,6 +16,8 @@ const { validateTries, emitInvalidHostnameWarning, getDefaultVerbatim, + setDefaultResultOrder, + setDefaultResolver, } = require('internal/dns/utils'); const { codes, dnsException } = require('internal/errors'); const { toASCII } = require('internal/idna'); @@ -312,6 +314,19 @@ Resolver.prototype.resolve = function resolve(hostname, rrtype) { return ReflectApply(resolver, this, [hostname]); }; +function defaultResolverSetServers(servers) { + const resolver = new Resolver(); -module.exports = { lookup, lookupService, Resolver }; + resolver.setServers(servers); + setDefaultResolver(resolver); + bindDefaultResolver(module.exports, Resolver.prototype); +} + +module.exports = { + lookup, + lookupService, + Resolver, + setDefaultResultOrder, + setServers: defaultResolverSetServers, +}; bindDefaultResolver(module.exports, Resolver.prototype);