diff --git a/doc/api/dns.md b/doc/api/dns.md index d0d3071cc8d203..5be30f22284b9c 100644 --- a/doc/api/dns.md +++ b/doc/api/dns.md @@ -54,6 +54,55 @@ dns.resolve4('archive.org', (err, addresses) => { There are subtle consequences in choosing one over the other, please consult the [Implementation considerations section][] for more information. +## Class dns.Resolver + + +An independent resolver for DNS requests. + +Note that creating a new resolver uses the default server settings. Setting +the servers used for a resolver using +[`resolver.setServers()`][`dns.setServers()`] does not affect +other resolver: + +```js +const { Resolver } = require('dns'); +const resolver = new Resolver(); +resolver.setServers(['4.4.4.4']); + +// This request will use the server at 4.4.4.4, independent of global settings. +resolver.resolve4('example.org', (err, addresses) => { + // ... +}); +``` + +The following methods from the `dns` module are available: + +* [`resolver.getServers()`][`dns.getServers()`] +* [`resolver.setServers()`][`dns.setServers()`] +* [`resolver.resolve()`][`dns.resolve()`] +* [`resolver.resolve4()`][`dns.resolve4()`] +* [`resolver.resolve6()`][`dns.resolve6()`] +* [`resolver.resolveAny()`][`dns.resolveAny()`] +* [`resolver.resolveCname()`][`dns.resolveCname()`] +* [`resolver.resolveMx()`][`dns.resolveMx()`] +* [`resolver.resolveNaptr()`][`dns.resolveNaptr()`] +* [`resolver.resolveNs()`][`dns.resolveNs()`] +* [`resolver.resolvePtr()`][`dns.resolvePtr()`] +* [`resolver.resolveSoa()`][`dns.resolveSoa()`] +* [`resolver.resolveSrv()`][`dns.resolveSrv()`] +* [`resolver.resolveTxt()`][`dns.resolveTxt()`] +* [`resolver.reverse()`][`dns.reverse()`] + +### resolver.cancel() + + +Cancel all outstanding DNS queries made by this resolver. The corresponding +callbacks will be called with an error with code `ECANCELLED`. + ## dns.getServers()