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() {
|
get() {
|
||||||
if (promises === null) {
|
if (promises === null) {
|
||||||
promises = require('internal/dns/promises');
|
promises = require('internal/dns/promises');
|
||||||
promises.setServers = defaultResolverSetServers;
|
|
||||||
promises.setDefaultResultOrder = setDefaultResultOrder;
|
|
||||||
}
|
}
|
||||||
return promises;
|
return promises;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const dnsPromises = require('internal/dns/promises');
|
module.exports = require('internal/dns/promises');
|
||||||
dnsPromises.setServers = require('dns').setServers;
|
|
||||||
module.exports = dnsPromises;
|
|
||||||
|
@ -17,6 +17,8 @@ const {
|
|||||||
emitInvalidHostnameWarning,
|
emitInvalidHostnameWarning,
|
||||||
getDefaultVerbatim,
|
getDefaultVerbatim,
|
||||||
errorCodes: dnsErrorCodes,
|
errorCodes: dnsErrorCodes,
|
||||||
|
setDefaultResultOrder,
|
||||||
|
setDefaultResolver,
|
||||||
} = require('internal/dns/utils');
|
} = require('internal/dns/utils');
|
||||||
const {
|
const {
|
||||||
NODATA,
|
NODATA,
|
||||||
@ -349,11 +351,20 @@ Resolver.prototype.resolve = function resolve(hostname, rrtype) {
|
|||||||
return ReflectApply(resolver, this, [hostname]);
|
return ReflectApply(resolver, this, [hostname]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function defaultResolverSetServers(servers) {
|
||||||
|
const resolver = new Resolver();
|
||||||
|
|
||||||
|
resolver.setServers(servers);
|
||||||
|
setDefaultResolver(resolver);
|
||||||
|
bindDefaultResolver(module.exports, Resolver.prototype);
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
lookup,
|
lookup,
|
||||||
lookupService,
|
lookupService,
|
||||||
Resolver,
|
Resolver,
|
||||||
|
setDefaultResultOrder,
|
||||||
|
setServers: defaultResolverSetServers,
|
||||||
|
|
||||||
// ERROR CODES
|
// ERROR CODES
|
||||||
NODATA,
|
NODATA,
|
||||||
|
Loading…
Reference in New Issue
Block a user