mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
dns: make promise API fully constructed from lib/internal/dns/promises
PR-URL: https://github.com/nodejs/node/pull/43227 Refs: https://github.com/nodejs/node/discussions/43198 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
This commit is contained in:
parent
f9db8840ad
commit
3847617f55
@ -439,8 +439,6 @@ ObjectDefineProperties(module.exports, {
|
||||
get() {
|
||||
if (promises === null) {
|
||||
promises = require('internal/dns/promises');
|
||||
promises.setServers = defaultResolverSetServers;
|
||||
promises.setDefaultResultOrder = setDefaultResultOrder;
|
||||
}
|
||||
return promises;
|
||||
}
|
||||
|
@ -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');
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user