Skip to content

Commit

Permalink
dns: move setServers to internal/dns/promise.js
Browse files Browse the repository at this point in the history
  • Loading branch information
F3n67u committed May 28, 2022
1 parent 29ff235 commit 663d400
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
1 change: 0 additions & 1 deletion lib/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ ObjectDefineProperties(module.exports, {
get() {
if (promises === null) {
promises = require('internal/dns/promises');
promises.setServers = defaultResolverSetServers;
}
return promises;
}
Expand Down
4 changes: 1 addition & 3 deletions lib/dns/promises.js
Original file line number Diff line number Diff line change
@@ -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');
16 changes: 15 additions & 1 deletion lib/internal/dns/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const {
emitInvalidHostnameWarning,
getDefaultVerbatim,
setDefaultResultOrder,
setDefaultResolver,
} = require('internal/dns/utils');
const { codes, dnsException } = require('internal/errors');
const { toASCII } = require('internal/idna');
Expand Down Expand Up @@ -313,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, setDefaultResultOrder };
resolver.setServers(servers);
setDefaultResolver(resolver);
bindDefaultResolver(module.exports, Resolver.prototype);
}

module.exports = {
lookup,
lookupService,
Resolver,
setDefaultResultOrder,
setServers: defaultResolverSetServers,
};
bindDefaultResolver(module.exports, Resolver.prototype);

0 comments on commit 663d400

Please sign in to comment.