/
opt
/
alt
/
alt-nodejs10
/
root
/
usr
/
share
/
doc
/
alt-nodejs10-nodejs-10.24.1
/
html
/
api
/
Upload Filee
HOME
{ "type": "module", "source": "doc/api/dns.md", "modules": [ { "textRaw": "DNS", "name": "dns", "introduced_in": "v0.10.0", "stability": 2, "stabilityText": "Stable", "desc": "<p>The <code>dns</code> module contains functions belonging to two different categories:</p>\n<p>1) Functions that use the underlying operating system facilities to perform\nname resolution, and that do not necessarily perform any network communication.\nThis category contains only one function: <a href=\"#dns_dns_lookup_hostname_options_callback\"><code>dns.lookup()</code></a>. <strong>Developers\nlooking to perform name resolution in the same way that other applications on\nthe same operating system behave should use <a href=\"#dns_dns_lookup_hostname_options_callback\"><code>dns.lookup()</code></a>.</strong></p>\n<p>For example, looking up <code>iana.org</code>.</p>\n<pre><code class=\"language-js\">const dns = require('dns');\n\ndns.lookup('iana.org', (err, address, family) => {\n console.log('address: %j family: IPv%s', address, family);\n});\n// address: \"192.0.43.8\" family: IPv4\n</code></pre>\n<p>2) Functions that connect to an actual DNS server to perform name resolution,\nand that <em>always</em> use the network to perform DNS queries. This category\ncontains all functions in the <code>dns</code> module <em>except</em> <a href=\"#dns_dns_lookup_hostname_options_callback\"><code>dns.lookup()</code></a>. These\nfunctions do not use the same set of configuration files used by\n<a href=\"#dns_dns_lookup_hostname_options_callback\"><code>dns.lookup()</code></a> (e.g. <code>/etc/hosts</code>). These functions should be used by\ndevelopers who do not want to use the underlying operating system's facilities\nfor name resolution, and instead want to <em>always</em> perform DNS queries.</p>\n<p>Below is an example that resolves <code>'archive.org'</code> then reverse resolves the IP\naddresses that are returned.</p>\n<pre><code class=\"language-js\">const dns = require('dns');\n\ndns.resolve4('archive.org', (err, addresses) => {\n if (err) throw err;\n\n console.log(`addresses: ${JSON.stringify(addresses)}`);\n\n addresses.forEach((a) => {\n dns.reverse(a, (err, hostnames) => {\n if (err) {\n throw err;\n }\n console.log(`reverse for ${a}: ${JSON.stringify(hostnames)}`);\n });\n });\n});\n</code></pre>\n<p>There are subtle consequences in choosing one over the other, please consult\nthe <a href=\"#dns_implementation_considerations\">Implementation considerations section</a> for more information.</p>", "modules": [ { "textRaw": "Class: `dns.Resolver`", "name": "class:_`dns.resolver`", "meta": { "added": [ "v8.3.0" ], "changes": [] }, "desc": "<p>An independent resolver for DNS requests.</p>\n<p>Note that creating a new resolver uses the default server settings. Setting\nthe servers used for a resolver using\n<a href=\"#dns_dns_setservers_servers\"><code>resolver.setServers()</code></a> does not affect\nother resolvers:</p>\n<pre><code class=\"language-js\">const { Resolver } = require('dns');\nconst resolver = new Resolver();\nresolver.setServers(['4.4.4.4']);\n\n// This request will use the server at 4.4.4.4, independent of global settings.\nresolver.resolve4('example.org', (err, addresses) => {\n // ...\n});\n</code></pre>\n<p>The following methods from the <code>dns</code> module are available:</p>\n<ul>\n<li><a href=\"#dns_dns_getservers\"><code>resolver.getServers()</code></a></li>\n<li><a href=\"#dns_dns_resolve_hostname_rrtype_callback\"><code>resolver.resolve()</code></a></li>\n<li><a href=\"#dns_dns_resolve4_hostname_options_callback\"><code>resolver.resolve4()</code></a></li>\n<li><a href=\"#dns_dns_resolve6_hostname_options_callback\"><code>resolver.resolve6()</code></a></li>\n<li><a href=\"#dns_dns_resolveany_hostname_callback\"><code>resolver.resolveAny()</code></a></li>\n<li><a href=\"#dns_dns_resolvecname_hostname_callback\"><code>resolver.resolveCname()</code></a></li>\n<li><a href=\"#dns_dns_resolvemx_hostname_callback\"><code>resolver.resolveMx()</code></a></li>\n<li><a href=\"#dns_dns_resolvenaptr_hostname_callback\"><code>resolver.resolveNaptr()</code></a></li>\n<li><a href=\"#dns_dns_resolvens_hostname_callback\"><code>resolver.resolveNs()</code></a></li>\n<li><a href=\"#dns_dns_resolveptr_hostname_callback\"><code>resolver.resolvePtr()</code></a></li>\n<li><a href=\"#dns_dns_resolvesoa_hostname_callback\"><code>resolver.resolveSoa()</code></a></li>\n<li><a href=\"#dns_dns_resolvesrv_hostname_callback\"><code>resolver.resolveSrv()</code></a></li>\n<li><a href=\"#dns_dns_resolvetxt_hostname_callback\"><code>resolver.resolveTxt()</code></a></li>\n<li><a href=\"#dns_dns_reverse_ip_callback\"><code>resolver.reverse()</code></a></li>\n<li><a href=\"#dns_dns_setservers_servers\"><code>resolver.setServers()</code></a></li>\n</ul>", "modules": [ { "textRaw": "`resolver.cancel()`", "name": "`resolver.cancel()`", "meta": { "added": [ "v8.3.0" ], "changes": [] }, "desc": "<p>Cancel all outstanding DNS queries made by this resolver. The corresponding\ncallbacks will be called with an error with code <code>ECANCELLED</code>.</p>", "type": "module", "displayName": "`resolver.cancel()`" } ], "type": "module", "displayName": "Class: `dns.Resolver`" }, { "textRaw": "`dns.getServers()`", "name": "`dns.getservers()`", "meta": { "added": [ "v0.11.3" ], "changes": [] }, "desc": "<ul>\n<li>Returns: <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string[]></a></li>\n</ul>\n<p>Returns an array of IP address strings, formatted according to <a href=\"https://tools.ietf.org/html/rfc5952#section-6\">rfc5952</a>,\nthat are currently configured for DNS resolution. A string will include a port\nsection if a custom port is used.</p>\n<!-- eslint-disable semi-->\n<pre><code class=\"language-js\">[\n '4.4.4.4',\n '2001:4860:4860::8888',\n '4.4.4.4:1053',\n '[2001:4860:4860::8888]:1053'\n]\n</code></pre>", "type": "module", "displayName": "`dns.getServers()`" }, { "textRaw": "`dns.lookup(hostname[, options], callback)`", "name": "`dns.lookup(hostname[,_options],_callback)`", "meta": { "added": [ "v0.1.90" ], "changes": [ { "version": "v8.5.0", "pr-url": "https://github.com/nodejs/node/pull/14731", "description": "The `verbatim` option is supported now." }, { "version": "v1.2.0", "pr-url": "https://github.com/nodejs/node/pull/744", "description": "The `all` option is supported now." } ] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n<li>\n<p><code>options</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\"><integer></a> | <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object></a></p>\n<ul>\n<li><code>family</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\"><integer></a> The record family. Must be <code>4</code> or <code>6</code>. IPv4\nand IPv6 addresses are both returned by default.</li>\n<li><code>hints</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\"><number></a> One or more <a href=\"#dns_supported_getaddrinfo_flags\">supported <code>getaddrinfo</code> flags</a>. Multiple\nflags may be passed by bitwise <code>OR</code>ing their values.</li>\n<li><code>all</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type\" class=\"type\"><boolean></a> When <code>true</code>, the callback returns all resolved addresses in\nan array. Otherwise, returns a single address. <strong>Default:</strong> <code>false</code>.</li>\n<li><code>verbatim</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type\" class=\"type\"><boolean></a> When <code>true</code>, the callback receives IPv4 and IPv6\naddresses in the order the DNS resolver returned them. When <code>false</code>,\nIPv4 addresses are placed before IPv6 addresses.\n<strong>Default:</strong> currently <code>false</code> (addresses are reordered) but this is\nexpected to change in the not too distant future.\nNew code should use <code>{ verbatim: true }</code>.</li>\n</ul>\n</li>\n<li>\n<p><code>callback</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"type\"><Function></a></p>\n<ul>\n<li><code>err</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error\" class=\"type\"><Error></a></li>\n<li><code>address</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a> A string representation of an IPv4 or IPv6 address.</li>\n<li><code>family</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\"><integer></a> <code>4</code> or <code>6</code>, denoting the family of <code>address</code>.</li>\n</ul>\n</li>\n</ul>\n<p>Resolves a hostname (e.g. <code>'nodejs.org'</code>) into the first found A (IPv4) or\nAAAA (IPv6) record. All <code>option</code> properties are optional. If <code>options</code> is an\ninteger, then it must be <code>4</code> or <code>6</code> – if <code>options</code> is not provided, then IPv4\nand IPv6 addresses are both returned if found.</p>\n<p>With the <code>all</code> option set to <code>true</code>, the arguments for <code>callback</code> change to\n<code>(err, addresses)</code>, with <code>addresses</code> being an array of objects with the\nproperties <code>address</code> and <code>family</code>.</p>\n<p>On error, <code>err</code> is an <a href=\"errors.html#errors_class_error\"><code>Error</code></a> object, where <code>err.code</code> is the error code.\nKeep in mind that <code>err.code</code> will be set to <code>'ENOENT'</code> not only when\nthe hostname does not exist but also when the lookup fails in other ways\nsuch as no available file descriptors.</p>\n<p><code>dns.lookup()</code> does not necessarily have anything to do with the DNS protocol.\nThe implementation uses an operating system facility that can associate names\nwith addresses, and vice versa. This implementation can have subtle but\nimportant consequences on the behavior of any Node.js program. Please take some\ntime to consult the <a href=\"#dns_implementation_considerations\">Implementation considerations section</a> before using\n<code>dns.lookup()</code>.</p>\n<p>Example usage:</p>\n<pre><code class=\"language-js\">const dns = require('dns');\nconst options = {\n family: 6,\n hints: dns.ADDRCONFIG | dns.V4MAPPED,\n};\ndns.lookup('example.com', options, (err, address, family) =>\n console.log('address: %j family: IPv%s', address, family));\n// address: \"2606:2800:220:1:248:1893:25c8:1946\" family: IPv6\n\n// When options.all is true, the result will be an Array.\noptions.all = true;\ndns.lookup('example.com', options, (err, addresses) =>\n console.log('addresses: %j', addresses));\n// addresses: [{\"address\":\"2606:2800:220:1:248:1893:25c8:1946\",\"family\":6}]\n</code></pre>\n<p>If this method is invoked as its <a href=\"util.html#util_util_promisify_original\"><code>util.promisify()</code></a>ed version, and <code>all</code>\nis not set to <code>true</code>, it returns a <code>Promise</code> for an <code>Object</code> with <code>address</code> and\n<code>family</code> properties.</p>", "modules": [ { "textRaw": "Supported getaddrinfo flags", "name": "supported_getaddrinfo_flags", "desc": "<p>The following flags can be passed as hints to <a href=\"#dns_dns_lookup_hostname_options_callback\"><code>dns.lookup()</code></a>.</p>\n<ul>\n<li><code>dns.ADDRCONFIG</code>: Returned address types are determined by the types\nof addresses supported by the current system. For example, IPv4 addresses\nare only returned if the current system has at least one IPv4 address\nconfigured. Loopback addresses are not considered.</li>\n<li><code>dns.V4MAPPED</code>: If the IPv6 family was specified, but no IPv6 addresses were\nfound, then return IPv4 mapped IPv6 addresses. Note that it is not supported\non some operating systems (e.g FreeBSD 10.1).</li>\n</ul>", "type": "module", "displayName": "Supported getaddrinfo flags" } ], "type": "module", "displayName": "`dns.lookup(hostname[, options], callback)`" }, { "textRaw": "`dns.lookupService(address, port, callback)`", "name": "`dns.lookupservice(address,_port,_callback)`", "meta": { "added": [ "v0.11.14" ], "changes": [] }, "desc": "<ul>\n<li><code>address</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n<li><code>port</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\"><number></a></li>\n<li>\n<p><code>callback</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"type\"><Function></a></p>\n<ul>\n<li><code>err</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error\" class=\"type\"><Error></a></li>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a> e.g. <code>example.com</code></li>\n<li><code>service</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a> e.g. <code>http</code></li>\n</ul>\n</li>\n</ul>\n<p>Resolves the given <code>address</code> and <code>port</code> into a hostname and service using\nthe operating system's underlying <code>getnameinfo</code> implementation.</p>\n<p>If <code>address</code> is not a valid IP address, a <code>TypeError</code> will be thrown.\nThe <code>port</code> will be coerced to a number. If it is not a legal port, a <code>TypeError</code>\nwill be thrown.</p>\n<p>On an error, <code>err</code> is an <a href=\"errors.html#errors_class_error\"><code>Error</code></a> object, where <code>err.code</code> is the error code.</p>\n<pre><code class=\"language-js\">const dns = require('dns');\ndns.lookupService('127.0.0.1', 22, (err, hostname, service) => {\n console.log(hostname, service);\n // Prints: localhost ssh\n});\n</code></pre>\n<p>If this method is invoked as its <a href=\"util.html#util_util_promisify_original\"><code>util.promisify()</code></a>ed version, it returns a\n<code>Promise</code> for an <code>Object</code> with <code>hostname</code> and <code>service</code> properties.</p>", "type": "module", "displayName": "`dns.lookupService(address, port, callback)`" }, { "textRaw": "`dns.resolve(hostname[, rrtype], callback)`", "name": "`dns.resolve(hostname[,_rrtype],_callback)`", "meta": { "added": [ "v0.1.27" ], "changes": [] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a> Hostname to resolve.</li>\n<li><code>rrtype</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a> Resource record type. <strong>Default:</strong> <code>'A'</code>.</li>\n<li>\n<p><code>callback</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"type\"><Function></a></p>\n<ul>\n<li><code>err</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error\" class=\"type\"><Error></a></li>\n<li><code>records</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string[]></a> | <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object[]></a> | <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object></a></li>\n</ul>\n</li>\n</ul>\n<p>Uses the DNS protocol to resolve a hostname (e.g. <code>'nodejs.org'</code>) into an array\nof the resource records. The <code>callback</code> function has arguments\n<code>(err, records)</code>. When successful, <code>records</code> will be an array of resource\nrecords. The type and structure of individual results varies based on <code>rrtype</code>:</p>\n<table>\n<thead>\n<tr>\n<th><code>rrtype</code></th>\n<th><code>records</code> contains</th>\n<th>Result type</th>\n<th>Shorthand method</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>'A'</code></td>\n<td>IPv4 addresses (default)</td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></td>\n<td><a href=\"#dns_dns_resolve4_hostname_options_callback\"><code>dns.resolve4()</code></a></td>\n</tr>\n<tr>\n<td><code>'AAAA'</code></td>\n<td>IPv6 addresses</td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></td>\n<td><a href=\"#dns_dns_resolve6_hostname_options_callback\"><code>dns.resolve6()</code></a></td>\n</tr>\n<tr>\n<td><code>'ANY'</code></td>\n<td>any records</td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object></a></td>\n<td><a href=\"#dns_dns_resolveany_hostname_callback\"><code>dns.resolveAny()</code></a></td>\n</tr>\n<tr>\n<td><code>'CNAME'</code></td>\n<td>canonical name records</td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></td>\n<td><a href=\"#dns_dns_resolvecname_hostname_callback\"><code>dns.resolveCname()</code></a></td>\n</tr>\n<tr>\n<td><code>'MX'</code></td>\n<td>mail exchange records</td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object></a></td>\n<td><a href=\"#dns_dns_resolvemx_hostname_callback\"><code>dns.resolveMx()</code></a></td>\n</tr>\n<tr>\n<td><code>'NAPTR'</code></td>\n<td>name authority pointer records</td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object></a></td>\n<td><a href=\"#dns_dns_resolvenaptr_hostname_callback\"><code>dns.resolveNaptr()</code></a></td>\n</tr>\n<tr>\n<td><code>'NS'</code></td>\n<td>name server records</td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></td>\n<td><a href=\"#dns_dns_resolvens_hostname_callback\"><code>dns.resolveNs()</code></a></td>\n</tr>\n<tr>\n<td><code>'PTR'</code></td>\n<td>pointer records</td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></td>\n<td><a href=\"#dns_dns_resolveptr_hostname_callback\"><code>dns.resolvePtr()</code></a></td>\n</tr>\n<tr>\n<td><code>'SOA'</code></td>\n<td>start of authority records</td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object></a></td>\n<td><a href=\"#dns_dns_resolvesoa_hostname_callback\"><code>dns.resolveSoa()</code></a></td>\n</tr>\n<tr>\n<td><code>'SRV'</code></td>\n<td>service records</td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object></a></td>\n<td><a href=\"#dns_dns_resolvesrv_hostname_callback\"><code>dns.resolveSrv()</code></a></td>\n</tr>\n<tr>\n<td><code>'TXT'</code></td>\n<td>text records</td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string[]></a></td>\n<td><a href=\"#dns_dns_resolvetxt_hostname_callback\"><code>dns.resolveTxt()</code></a></td>\n</tr>\n</tbody>\n</table>\n<p>On error, <code>err</code> is an <a href=\"errors.html#errors_class_error\"><code>Error</code></a> object, where <code>err.code</code> is one of the\n<a href=\"#dns_error_codes\">DNS error codes</a>.</p>", "type": "module", "displayName": "`dns.resolve(hostname[, rrtype], callback)`" }, { "textRaw": "`dns.resolve4(hostname[, options], callback)`", "name": "`dns.resolve4(hostname[,_options],_callback)`", "meta": { "added": [ "v0.1.16" ], "changes": [ { "version": "v7.2.0", "pr-url": "https://github.com/nodejs/node/pull/9296", "description": "This method now supports passing `options`, specifically `options.ttl`." } ] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a> Hostname to resolve.</li>\n<li>\n<p><code>options</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object></a></p>\n<ul>\n<li><code>ttl</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type\" class=\"type\"><boolean></a> Retrieve the Time-To-Live value (TTL) of each record.\nWhen <code>true</code>, the callback receives an array of\n<code>{ address: '1.2.3.4', ttl: 60 }</code> objects rather than an array of strings,\nwith the TTL expressed in seconds.</li>\n</ul>\n</li>\n<li>\n<p><code>callback</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"type\"><Function></a></p>\n<ul>\n<li><code>err</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error\" class=\"type\"><Error></a></li>\n<li><code>addresses</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string[]></a> | <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object[]></a></li>\n</ul>\n</li>\n</ul>\n<p>Uses the DNS protocol to resolve a IPv4 addresses (<code>A</code> records) for the\n<code>hostname</code>. The <code>addresses</code> argument passed to the <code>callback</code> function\nwill contain an array of IPv4 addresses (e.g.\n<code>['74.125.79.104', '74.125.79.105', '74.125.79.106']</code>).</p>", "type": "module", "displayName": "`dns.resolve4(hostname[, options], callback)`" }, { "textRaw": "`dns.resolve6(hostname[, options], callback)`", "name": "`dns.resolve6(hostname[,_options],_callback)`", "meta": { "added": [ "v0.1.16" ], "changes": [ { "version": "v7.2.0", "pr-url": "https://github.com/nodejs/node/pull/9296", "description": "This method now supports passing `options`, specifically `options.ttl`." } ] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a> Hostname to resolve.</li>\n<li>\n<p><code>options</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object></a></p>\n<ul>\n<li><code>ttl</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type\" class=\"type\"><boolean></a> Retrieve the Time-To-Live value (TTL) of each record.\nWhen <code>true</code>, the callback receives an array of\n<code>{ address: '0:1:2:3:4:5:6:7', ttl: 60 }</code> objects rather than an array of\nstrings, with the TTL expressed in seconds.</li>\n</ul>\n</li>\n<li>\n<p><code>callback</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"type\"><Function></a></p>\n<ul>\n<li><code>err</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error\" class=\"type\"><Error></a></li>\n<li><code>addresses</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string[]></a> | <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object[]></a></li>\n</ul>\n</li>\n</ul>\n<p>Uses the DNS protocol to resolve a IPv6 addresses (<code>AAAA</code> records) for the\n<code>hostname</code>. The <code>addresses</code> argument passed to the <code>callback</code> function\nwill contain an array of IPv6 addresses.</p>", "type": "module", "displayName": "`dns.resolve6(hostname[, options], callback)`" }, { "textRaw": "`dns.resolveAny(hostname, callback)`", "name": "`dns.resolveany(hostname,_callback)`", "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n<li>\n<p><code>callback</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"type\"><Function></a></p>\n<ul>\n<li><code>err</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error\" class=\"type\"><Error></a></li>\n<li><code>ret</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object[]></a></li>\n</ul>\n</li>\n</ul>\n<p>Uses the DNS protocol to resolve all records (also known as <code>ANY</code> or <code>*</code> query).\nThe <code>ret</code> argument passed to the <code>callback</code> function will be an array containing\nvarious types of records. Each object has a property <code>type</code> that indicates the\ntype of the current record. And depending on the <code>type</code>, additional properties\nwill be present on the object:</p>\n<table>\n<thead>\n<tr>\n<th>Type</th>\n<th>Properties</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>'A'</code></td>\n<td><code>address</code>/<code>ttl</code></td>\n</tr>\n<tr>\n<td><code>'AAAA'</code></td>\n<td><code>address</code>/<code>ttl</code></td>\n</tr>\n<tr>\n<td><code>'CNAME'</code></td>\n<td><code>value</code></td>\n</tr>\n<tr>\n<td><code>'MX'</code></td>\n<td>Refer to <a href=\"#dns_dns_resolvemx_hostname_callback\"><code>dns.resolveMx()</code></a></td>\n</tr>\n<tr>\n<td><code>'NAPTR'</code></td>\n<td>Refer to <a href=\"#dns_dns_resolvenaptr_hostname_callback\"><code>dns.resolveNaptr()</code></a></td>\n</tr>\n<tr>\n<td><code>'NS'</code></td>\n<td><code>value</code></td>\n</tr>\n<tr>\n<td><code>'PTR'</code></td>\n<td><code>value</code></td>\n</tr>\n<tr>\n<td><code>'SOA'</code></td>\n<td>Refer to <a href=\"#dns_dns_resolvesoa_hostname_callback\"><code>dns.resolveSoa()</code></a></td>\n</tr>\n<tr>\n<td><code>'SRV'</code></td>\n<td>Refer to <a href=\"#dns_dns_resolvesrv_hostname_callback\"><code>dns.resolveSrv()</code></a></td>\n</tr>\n<tr>\n<td><code>'TXT'</code></td>\n<td>This type of record contains an array property called <code>entries</code> which refers to <a href=\"#dns_dns_resolvetxt_hostname_callback\"><code>dns.resolveTxt()</code></a>, e.g. <code>{ entries: ['...'], type: 'TXT' }</code></td>\n</tr>\n</tbody>\n</table>\n<p>Here is an example of the <code>ret</code> object passed to the callback:</p>\n<!-- eslint-disable semi -->\n<pre><code class=\"language-js\">[ { type: 'A', address: '127.0.0.1', ttl: 299 },\n { type: 'CNAME', value: 'example.com' },\n { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 },\n { type: 'NS', value: 'ns1.example.com' },\n { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] },\n { type: 'SOA',\n nsname: 'ns1.example.com',\n hostmaster: 'admin.example.com',\n serial: 156696742,\n refresh: 900,\n retry: 900,\n expire: 1800,\n minttl: 60 } ]\n</code></pre>\n<p>DNS server operators may choose not to respond to <code>ANY</code>\nqueries. It may be better to call individual methods like <a href=\"#dns_dns_resolve4_hostname_options_callback\"><code>dns.resolve4()</code></a>,\n<a href=\"#dns_dns_resolvemx_hostname_callback\"><code>dns.resolveMx()</code></a>, and so on. For more details, see <a href=\"https://tools.ietf.org/html/rfc8482\">RFC 8482</a>.</p>", "type": "module", "displayName": "`dns.resolveAny(hostname, callback)`" }, { "textRaw": "`dns.resolveCname(hostname, callback)`", "name": "`dns.resolvecname(hostname,_callback)`", "meta": { "added": [ "v0.3.2" ], "changes": [] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n<li>\n<p><code>callback</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"type\"><Function></a></p>\n<ul>\n<li><code>err</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error\" class=\"type\"><Error></a></li>\n<li><code>addresses</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string[]></a></li>\n</ul>\n</li>\n</ul>\n<p>Uses the DNS protocol to resolve <code>CNAME</code> records for the <code>hostname</code>. The\n<code>addresses</code> argument passed to the <code>callback</code> function\nwill contain an array of canonical name records available for the <code>hostname</code>\n(e.g. <code>['bar.example.com']</code>).</p>", "type": "module", "displayName": "`dns.resolveCname(hostname, callback)`" }, { "textRaw": "`dns.resolveMx(hostname, callback)`", "name": "`dns.resolvemx(hostname,_callback)`", "meta": { "added": [ "v0.1.27" ], "changes": [] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n<li>\n<p><code>callback</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"type\"><Function></a></p>\n<ul>\n<li><code>err</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error\" class=\"type\"><Error></a></li>\n<li><code>addresses</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object[]></a></li>\n</ul>\n</li>\n</ul>\n<p>Uses the DNS protocol to resolve mail exchange records (<code>MX</code> records) for the\n<code>hostname</code>. The <code>addresses</code> argument passed to the <code>callback</code> function will\ncontain an array of objects containing both a <code>priority</code> and <code>exchange</code>\nproperty (e.g. <code>[{priority: 10, exchange: 'mx.example.com'}, ...]</code>).</p>", "type": "module", "displayName": "`dns.resolveMx(hostname, callback)`" }, { "textRaw": "`dns.resolveNaptr(hostname, callback)`", "name": "`dns.resolvenaptr(hostname,_callback)`", "meta": { "added": [ "v0.9.12" ], "changes": [] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n<li>\n<p><code>callback</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"type\"><Function></a></p>\n<ul>\n<li><code>err</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error\" class=\"type\"><Error></a></li>\n<li><code>addresses</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object[]></a></li>\n</ul>\n</li>\n</ul>\n<p>Uses the DNS protocol to resolve regular expression based records (<code>NAPTR</code>\nrecords) for the <code>hostname</code>. The <code>addresses</code> argument passed to the <code>callback</code>\nfunction will contain an array of objects with the following properties:</p>\n<ul>\n<li><code>flags</code></li>\n<li><code>service</code></li>\n<li><code>regexp</code></li>\n<li><code>replacement</code></li>\n<li><code>order</code></li>\n<li><code>preference</code></li>\n</ul>\n<!-- eslint-skip -->\n<pre><code class=\"language-js\">{\n flags: 's',\n service: 'SIP+D2U',\n regexp: '',\n replacement: '_sip._udp.example.com',\n order: 30,\n preference: 100\n}\n</code></pre>", "type": "module", "displayName": "`dns.resolveNaptr(hostname, callback)`" }, { "textRaw": "`dns.resolveNs(hostname, callback)`", "name": "`dns.resolvens(hostname,_callback)`", "meta": { "added": [ "v0.1.90" ], "changes": [] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n<li>\n<p><code>callback</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"type\"><Function></a></p>\n<ul>\n<li><code>err</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error\" class=\"type\"><Error></a></li>\n<li><code>addresses</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string[]></a></li>\n</ul>\n</li>\n</ul>\n<p>Uses the DNS protocol to resolve name server records (<code>NS</code> records) for the\n<code>hostname</code>. The <code>addresses</code> argument passed to the <code>callback</code> function will\ncontain an array of name server records available for <code>hostname</code>\n(e.g. <code>['ns1.example.com', 'ns2.example.com']</code>).</p>", "type": "module", "displayName": "`dns.resolveNs(hostname, callback)`" }, { "textRaw": "`dns.resolvePtr(hostname, callback)`", "name": "`dns.resolveptr(hostname,_callback)`", "meta": { "added": [ "v6.0.0" ], "changes": [] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n<li>\n<p><code>callback</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"type\"><Function></a></p>\n<ul>\n<li><code>err</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error\" class=\"type\"><Error></a></li>\n<li><code>addresses</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string[]></a></li>\n</ul>\n</li>\n</ul>\n<p>Uses the DNS protocol to resolve pointer records (<code>PTR</code> records) for the\n<code>hostname</code>. The <code>addresses</code> argument passed to the <code>callback</code> function will\nbe an array of strings containing the reply records.</p>", "type": "module", "displayName": "`dns.resolvePtr(hostname, callback)`" }, { "textRaw": "`dns.resolveSoa(hostname, callback)`", "name": "`dns.resolvesoa(hostname,_callback)`", "meta": { "added": [ "v0.11.10" ], "changes": [] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n<li>\n<p><code>callback</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"type\"><Function></a></p>\n<ul>\n<li><code>err</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error\" class=\"type\"><Error></a></li>\n<li><code>address</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object></a></li>\n</ul>\n</li>\n</ul>\n<p>Uses the DNS protocol to resolve a start of authority record (<code>SOA</code> record) for\nthe <code>hostname</code>. The <code>address</code> argument passed to the <code>callback</code> function will\nbe an object with the following properties:</p>\n<ul>\n<li><code>nsname</code></li>\n<li><code>hostmaster</code></li>\n<li><code>serial</code></li>\n<li><code>refresh</code></li>\n<li><code>retry</code></li>\n<li><code>expire</code></li>\n<li><code>minttl</code></li>\n</ul>\n<!-- eslint-skip -->\n<pre><code class=\"language-js\">{\n nsname: 'ns.example.com',\n hostmaster: 'root.example.com',\n serial: 2013101809,\n refresh: 10000,\n retry: 2400,\n expire: 604800,\n minttl: 3600\n}\n</code></pre>", "type": "module", "displayName": "`dns.resolveSoa(hostname, callback)`" }, { "textRaw": "`dns.resolveSrv(hostname, callback)`", "name": "`dns.resolvesrv(hostname,_callback)`", "meta": { "added": [ "v0.1.27" ], "changes": [] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n<li>\n<p><code>callback</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"type\"><Function></a></p>\n<ul>\n<li><code>err</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error\" class=\"type\"><Error></a></li>\n<li><code>addresses</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object[]></a></li>\n</ul>\n</li>\n</ul>\n<p>Uses the DNS protocol to resolve service records (<code>SRV</code> records) for the\n<code>hostname</code>. The <code>addresses</code> argument passed to the <code>callback</code> function will\nbe an array of objects with the following properties:</p>\n<ul>\n<li><code>priority</code></li>\n<li><code>weight</code></li>\n<li><code>port</code></li>\n<li><code>name</code></li>\n</ul>\n<!-- eslint-skip -->\n<pre><code class=\"language-js\">{\n priority: 10,\n weight: 5,\n port: 21223,\n name: 'service.example.com'\n}\n</code></pre>", "type": "module", "displayName": "`dns.resolveSrv(hostname, callback)`" }, { "textRaw": "`dns.resolveTxt(hostname, callback)`", "name": "`dns.resolvetxt(hostname,_callback)`", "meta": { "added": [ "v0.1.27" ], "changes": [] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n<li>\n<p><code>callback</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"type\"><Function></a></p>\n<ul>\n<li><code>err</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error\" class=\"type\"><Error></a></li>\n<li><code>records</code> {string[][]}</li>\n</ul>\n</li>\n</ul>\n<p>Uses the DNS protocol to resolve text queries (<code>TXT</code> records) for the\n<code>hostname</code>. The <code>records</code> argument passed to the <code>callback</code> function is a\ntwo-dimensional array of the text records available for <code>hostname</code> (e.g.\n<code>[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]</code>). Each sub-array contains TXT chunks of\none record. Depending on the use case, these could be either joined together or\ntreated separately.</p>", "type": "module", "displayName": "`dns.resolveTxt(hostname, callback)`" }, { "textRaw": "`dns.reverse(ip, callback)`", "name": "`dns.reverse(ip,_callback)`", "meta": { "added": [ "v0.1.16" ], "changes": [] }, "desc": "<ul>\n<li><code>ip</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n<li>\n<p><code>callback</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"type\"><Function></a></p>\n<ul>\n<li><code>err</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error\" class=\"type\"><Error></a></li>\n<li><code>hostnames</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string[]></a></li>\n</ul>\n</li>\n</ul>\n<p>Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an\narray of hostnames.</p>\n<p>On error, <code>err</code> is an <a href=\"errors.html#errors_class_error\"><code>Error</code></a> object, where <code>err.code</code> is\none of the <a href=\"#dns_error_codes\">DNS error codes</a>.</p>", "type": "module", "displayName": "`dns.reverse(ip, callback)`" }, { "textRaw": "`dns.setServers(servers)`", "name": "`dns.setservers(servers)`", "meta": { "added": [ "v0.11.3" ], "changes": [] }, "desc": "<ul>\n<li><code>servers</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string[]></a> array of <a href=\"https://tools.ietf.org/html/rfc5952#section-6\">rfc5952</a> formatted addresses</li>\n</ul>\n<p>Sets the IP address and port of servers to be used when performing DNS\nresolution. The <code>servers</code> argument is an array of <a href=\"https://tools.ietf.org/html/rfc5952#section-6\">rfc5952</a> formatted\naddresses. If the port is the IANA default DNS port (53) it can be omitted.</p>\n<pre><code class=\"language-js\">dns.setServers([\n '4.4.4.4',\n '[2001:4860:4860::8888]',\n '4.4.4.4:1053',\n '[2001:4860:4860::8888]:1053'\n]);\n</code></pre>\n<p>An error will be thrown if an invalid address is provided.</p>\n<p>The <code>dns.setServers()</code> method must not be called while a DNS query is in\nprogress.</p>\n<p>The <a href=\"#dns_dns_setservers_servers\"><code>dns.setServers()</code></a> method affects only <a href=\"#dns_dns_resolve_hostname_rrtype_callback\"><code>dns.resolve()</code></a>,\n[<code>dns.resolve*()</code>][] and <a href=\"#dns_dns_reverse_ip_callback\"><code>dns.reverse()</code></a> (and specifically <em>not</em>\n<a href=\"#dns_dns_lookup_hostname_options_callback\"><code>dns.lookup()</code></a>).</p>\n<p>Note that this method works much like\n<a href=\"http://man7.org/linux/man-pages/man5/resolv.conf.5.html\">resolve.conf</a>.\nThat is, if attempting to resolve with the first server provided results in a\n<code>NOTFOUND</code> error, the <code>resolve()</code> method will <em>not</em> attempt to resolve with\nsubsequent servers provided. Fallback DNS servers will only be used if the\nearlier ones time out or result in some other error.</p>", "type": "module", "displayName": "`dns.setServers(servers)`" }, { "textRaw": "DNS Promises API", "name": "dns_promises_api", "stability": 2, "stabilityText": "Stable", "desc": "<p>The <code>dns.promises</code> API provides an alternative set of asynchronous DNS methods\nthat return <code>Promise</code> objects rather than using callbacks. The API is accessible\nvia <code>require('dns').promises</code>.</p>", "modules": [ { "textRaw": "Class: `dnsPromises.Resolver`", "name": "class:_`dnspromises.resolver`", "meta": { "added": [ "v10.6.0" ], "changes": [] }, "desc": "<p>An independent resolver for DNS requests.</p>\n<p>Note that creating a new resolver uses the default server settings. Setting\nthe servers used for a resolver using\n<a href=\"#dns_dnspromises_setservers_servers\"><code>resolver.setServers()</code></a> does not affect\nother resolvers:</p>\n<pre><code class=\"language-js\">const { Resolver } = require('dns').promises;\nconst resolver = new Resolver();\nresolver.setServers(['4.4.4.4']);\n\n// This request will use the server at 4.4.4.4, independent of global settings.\nresolver.resolve4('example.org').then((addresses) => {\n // ...\n});\n\n// Alternatively, the same code can be written using async-await style.\n(async function() {\n const addresses = await resolver.resolve4('example.org');\n})();\n</code></pre>\n<p>The following methods from the <code>dnsPromises</code> API are available:</p>\n<ul>\n<li><a href=\"#dns_dnspromises_getservers\"><code>resolver.getServers()</code></a></li>\n<li><a href=\"#dns_dnspromises_resolve_hostname_rrtype\"><code>resolver.resolve()</code></a></li>\n<li><a href=\"#dns_dnspromises_resolve4_hostname_options\"><code>resolver.resolve4()</code></a></li>\n<li><a href=\"#dns_dnspromises_resolve6_hostname_options\"><code>resolver.resolve6()</code></a></li>\n<li><a href=\"#dns_dnspromises_resolveany_hostname\"><code>resolver.resolveAny()</code></a></li>\n<li><a href=\"#dns_dnspromises_resolvecname_hostname\"><code>resolver.resolveCname()</code></a></li>\n<li><a href=\"#dns_dnspromises_resolvemx_hostname\"><code>resolver.resolveMx()</code></a></li>\n<li><a href=\"#dns_dnspromises_resolvenaptr_hostname\"><code>resolver.resolveNaptr()</code></a></li>\n<li><a href=\"#dns_dnspromises_resolvens_hostname\"><code>resolver.resolveNs()</code></a></li>\n<li><a href=\"#dns_dnspromises_resolveptr_hostname\"><code>resolver.resolvePtr()</code></a></li>\n<li><a href=\"#dns_dnspromises_resolvesoa_hostname\"><code>resolver.resolveSoa()</code></a></li>\n<li><a href=\"#dns_dnspromises_resolvesrv_hostname\"><code>resolver.resolveSrv()</code></a></li>\n<li><a href=\"#dns_dnspromises_resolvetxt_hostname\"><code>resolver.resolveTxt()</code></a></li>\n<li><a href=\"#dns_dnspromises_reverse_ip\"><code>resolver.reverse()</code></a></li>\n<li><a href=\"#dns_dnspromises_setservers_servers\"><code>resolver.setServers()</code></a></li>\n</ul>", "type": "module", "displayName": "Class: `dnsPromises.Resolver`" }, { "textRaw": "`dnsPromises.getServers()`", "name": "`dnspromises.getservers()`", "meta": { "added": [ "v10.6.0" ], "changes": [] }, "desc": "<ul>\n<li>Returns: <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string[]></a></li>\n</ul>\n<p>Returns an array of IP address strings, formatted according to <a href=\"https://tools.ietf.org/html/rfc5952#section-6\">rfc5952</a>,\nthat are currently configured for DNS resolution. A string will include a port\nsection if a custom port is used.</p>\n<!-- eslint-disable semi-->\n<pre><code class=\"language-js\">[\n '4.4.4.4',\n '2001:4860:4860::8888',\n '4.4.4.4:1053',\n '[2001:4860:4860::8888]:1053'\n]\n</code></pre>", "type": "module", "displayName": "`dnsPromises.getServers()`" }, { "textRaw": "`dnsPromises.lookup(hostname[, options])`", "name": "`dnspromises.lookup(hostname[,_options])`", "meta": { "added": [ "v10.6.0" ], "changes": [] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n<li>\n<p><code>options</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\"><integer></a> | <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object></a></p>\n<ul>\n<li><code>family</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\"><integer></a> The record family. Must be <code>4</code> or <code>6</code>. IPv4\nand IPv6 addresses are both returned by default.</li>\n<li><code>hints</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\"><number></a> One or more <a href=\"#dns_supported_getaddrinfo_flags\">supported <code>getaddrinfo</code> flags</a>. Multiple\nflags may be passed by bitwise <code>OR</code>ing their values.</li>\n<li><code>all</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type\" class=\"type\"><boolean></a> When <code>true</code>, the <code>Promise</code> is resolved with all addresses in\nan array. Otherwise, returns a single address. <strong>Default:</strong> <code>false</code>.</li>\n<li><code>verbatim</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type\" class=\"type\"><boolean></a> When <code>true</code>, the <code>Promise</code> is resolved with IPv4 and\nIPv6 addresses in the order the DNS resolver returned them. When <code>false</code>,\nIPv4 addresses are placed before IPv6 addresses.\n<strong>Default:</strong> currently <code>false</code> (addresses are reordered) but this is\nexpected to change in the not too distant future.\nNew code should use <code>{ verbatim: true }</code>.</li>\n</ul>\n</li>\n</ul>\n<p>Resolves a hostname (e.g. <code>'nodejs.org'</code>) into the first found A (IPv4) or\nAAAA (IPv6) record. All <code>option</code> properties are optional. If <code>options</code> is an\ninteger, then it must be <code>4</code> or <code>6</code> – if <code>options</code> is not provided, then IPv4\nand IPv6 addresses are both returned if found.</p>\n<p>With the <code>all</code> option set to <code>true</code>, the <code>Promise</code> is resolved with <code>addresses</code>\nbeing an array of objects with the properties <code>address</code> and <code>family</code>.</p>\n<p>On error, the <code>Promise</code> is rejected with an <a href=\"errors.html#errors_class_error\"><code>Error</code></a> object, where <code>err.code</code>\nis the error code.\nKeep in mind that <code>err.code</code> will be set to <code>'ENOENT'</code> not only when\nthe hostname does not exist but also when the lookup fails in other ways\nsuch as no available file descriptors.</p>\n<p><a href=\"#dns_dnspromises_lookup_hostname_options\"><code>dnsPromises.lookup()</code></a> does not necessarily have anything to do with the DNS\nprotocol. The implementation uses an operating system facility that can\nassociate names with addresses, and vice versa. This implementation can have\nsubtle but important consequences on the behavior of any Node.js program. Please\ntake some time to consult the <a href=\"#dns_implementation_considerations\">Implementation considerations section</a> before\nusing <code>dnsPromises.lookup()</code>.</p>\n<p>Example usage:</p>\n<pre><code class=\"language-js\">const dns = require('dns');\nconst dnsPromises = dns.promises;\nconst options = {\n family: 6,\n hints: dns.ADDRCONFIG | dns.V4MAPPED,\n};\n\ndnsPromises.lookup('example.com', options).then((result) => {\n console.log('address: %j family: IPv%s', result.address, result.family);\n // address: \"2606:2800:220:1:248:1893:25c8:1946\" family: IPv6\n});\n\n// When options.all is true, the result will be an Array.\noptions.all = true;\ndnsPromises.lookup('example.com', options).then((result) => {\n console.log('addresses: %j', result);\n // addresses: [{\"address\":\"2606:2800:220:1:248:1893:25c8:1946\",\"family\":6}]\n});\n</code></pre>", "type": "module", "displayName": "`dnsPromises.lookup(hostname[, options])`" }, { "textRaw": "`dnsPromises.lookupService(address, port)`", "name": "`dnspromises.lookupservice(address,_port)`", "meta": { "added": [ "v10.6.0" ], "changes": [] }, "desc": "<ul>\n<li><code>address</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n<li><code>port</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\"><number></a></li>\n</ul>\n<p>Resolves the given <code>address</code> and <code>port</code> into a hostname and service using\nthe operating system's underlying <code>getnameinfo</code> implementation.</p>\n<p>If <code>address</code> is not a valid IP address, a <code>TypeError</code> will be thrown.\nThe <code>port</code> will be coerced to a number. If it is not a legal port, a <code>TypeError</code>\nwill be thrown.</p>\n<p>On error, the <code>Promise</code> is rejected with an <a href=\"errors.html#errors_class_error\"><code>Error</code></a> object, where <code>err.code</code>\nis the error code.</p>\n<pre><code class=\"language-js\">const dnsPromises = require('dns').promises;\ndnsPromises.lookupService('127.0.0.1', 22).then((result) => {\n console.log(result.hostname, result.service);\n // Prints: localhost ssh\n});\n</code></pre>", "type": "module", "displayName": "`dnsPromises.lookupService(address, port)`" }, { "textRaw": "`dnsPromises.resolve(hostname[, rrtype])`", "name": "`dnspromises.resolve(hostname[,_rrtype])`", "meta": { "added": [ "v10.6.0" ], "changes": [] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a> Hostname to resolve.</li>\n<li><code>rrtype</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a> Resource record type. <strong>Default:</strong> <code>'A'</code>.</li>\n</ul>\n<p>Uses the DNS protocol to resolve a hostname (e.g. <code>'nodejs.org'</code>) into an array\nof the resource records. When successful, the <code>Promise</code> is resolved with an\narray of resource records. The type and structure of individual results vary\nbased on <code>rrtype</code>:</p>\n<table>\n<thead>\n<tr>\n<th><code>rrtype</code></th>\n<th><code>records</code> contains</th>\n<th>Result type</th>\n<th>Shorthand method</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>'A'</code></td>\n<td>IPv4 addresses (default)</td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></td>\n<td><a href=\"#dns_dnspromises_resolve4_hostname_options\"><code>dnsPromises.resolve4()</code></a></td>\n</tr>\n<tr>\n<td><code>'AAAA'</code></td>\n<td>IPv6 addresses</td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></td>\n<td><a href=\"#dns_dnspromises_resolve6_hostname_options\"><code>dnsPromises.resolve6()</code></a></td>\n</tr>\n<tr>\n<td><code>'ANY'</code></td>\n<td>any records</td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object></a></td>\n<td><a href=\"#dns_dnspromises_resolveany_hostname\"><code>dnsPromises.resolveAny()</code></a></td>\n</tr>\n<tr>\n<td><code>'CNAME'</code></td>\n<td>canonical name records</td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></td>\n<td><a href=\"#dns_dnspromises_resolvecname_hostname\"><code>dnsPromises.resolveCname()</code></a></td>\n</tr>\n<tr>\n<td><code>'MX'</code></td>\n<td>mail exchange records</td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object></a></td>\n<td><a href=\"#dns_dnspromises_resolvemx_hostname\"><code>dnsPromises.resolveMx()</code></a></td>\n</tr>\n<tr>\n<td><code>'NAPTR'</code></td>\n<td>name authority pointer records</td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object></a></td>\n<td><a href=\"#dns_dnspromises_resolvenaptr_hostname\"><code>dnsPromises.resolveNaptr()</code></a></td>\n</tr>\n<tr>\n<td><code>'NS'</code></td>\n<td>name server records</td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></td>\n<td><a href=\"#dns_dnspromises_resolvens_hostname\"><code>dnsPromises.resolveNs()</code></a></td>\n</tr>\n<tr>\n<td><code>'PTR'</code></td>\n<td>pointer records</td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></td>\n<td><a href=\"#dns_dnspromises_resolveptr_hostname\"><code>dnsPromises.resolvePtr()</code></a></td>\n</tr>\n<tr>\n<td><code>'SOA'</code></td>\n<td>start of authority records</td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object></a></td>\n<td><a href=\"#dns_dnspromises_resolvesoa_hostname\"><code>dnsPromises.resolveSoa()</code></a></td>\n</tr>\n<tr>\n<td><code>'SRV'</code></td>\n<td>service records</td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object></a></td>\n<td><a href=\"#dns_dnspromises_resolvesrv_hostname\"><code>dnsPromises.resolveSrv()</code></a></td>\n</tr>\n<tr>\n<td><code>'TXT'</code></td>\n<td>text records</td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string[]></a></td>\n<td><a href=\"#dns_dnspromises_resolvetxt_hostname\"><code>dnsPromises.resolveTxt()</code></a></td>\n</tr>\n</tbody>\n</table>\n<p>On error, the <code>Promise</code> is rejected with an <a href=\"errors.html#errors_class_error\"><code>Error</code></a> object, where <code>err.code</code>\nis one of the <a href=\"#dns_error_codes\">DNS error codes</a>.</p>", "type": "module", "displayName": "`dnsPromises.resolve(hostname[, rrtype])`" }, { "textRaw": "`dnsPromises.resolve4(hostname[, options])`", "name": "`dnspromises.resolve4(hostname[,_options])`", "meta": { "added": [ "v10.6.0" ], "changes": [] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a> Hostname to resolve.</li>\n<li>\n<p><code>options</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object></a></p>\n<ul>\n<li><code>ttl</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type\" class=\"type\"><boolean></a> Retrieve the Time-To-Live value (TTL) of each record.\nWhen <code>true</code>, the <code>Promise</code> is resolved with an array of\n<code>{ address: '1.2.3.4', ttl: 60 }</code> objects rather than an array of strings,\nwith the TTL expressed in seconds.</li>\n</ul>\n</li>\n</ul>\n<p>Uses the DNS protocol to resolve IPv4 addresses (<code>A</code> records) for the\n<code>hostname</code>. On success, the <code>Promise</code> is resolved with an array of IPv4\naddresses (e.g. <code>['74.125.79.104', '74.125.79.105', '74.125.79.106']</code>).</p>", "type": "module", "displayName": "`dnsPromises.resolve4(hostname[, options])`" }, { "textRaw": "`dnsPromises.resolve6(hostname[, options])`", "name": "`dnspromises.resolve6(hostname[,_options])`", "meta": { "added": [ "v10.6.0" ], "changes": [] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a> Hostname to resolve.</li>\n<li>\n<p><code>options</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\"><Object></a></p>\n<ul>\n<li><code>ttl</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type\" class=\"type\"><boolean></a> Retrieve the Time-To-Live value (TTL) of each record.\nWhen <code>true</code>, the <code>Promise</code> is resolved with an array of\n<code>{ address: '0:1:2:3:4:5:6:7', ttl: 60 }</code> objects rather than an array of\nstrings, with the TTL expressed in seconds.</li>\n</ul>\n</li>\n</ul>\n<p>Uses the DNS protocol to resolve IPv6 addresses (<code>AAAA</code> records) for the\n<code>hostname</code>. On success, the <code>Promise</code> is resolved with an array of IPv6\naddresses.</p>", "type": "module", "displayName": "`dnsPromises.resolve6(hostname[, options])`" }, { "textRaw": "`dnsPromises.resolveAny(hostname)`", "name": "`dnspromises.resolveany(hostname)`", "meta": { "added": [ "v10.6.0" ], "changes": [] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n</ul>\n<p>Uses the DNS protocol to resolve all records (also known as <code>ANY</code> or <code>*</code> query).\nOn success, the <code>Promise</code> is resolved with an array containing various types of\nrecords. Each object has a property <code>type</code> that indicates the type of the\ncurrent record. And depending on the <code>type</code>, additional properties will be\npresent on the object:</p>\n<table>\n<thead>\n<tr>\n<th>Type</th>\n<th>Properties</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>'A'</code></td>\n<td><code>address</code>/<code>ttl</code></td>\n</tr>\n<tr>\n<td><code>'AAAA'</code></td>\n<td><code>address</code>/<code>ttl</code></td>\n</tr>\n<tr>\n<td><code>'CNAME'</code></td>\n<td><code>value</code></td>\n</tr>\n<tr>\n<td><code>'MX'</code></td>\n<td>Refer to <a href=\"#dns_dnspromises_resolvemx_hostname\"><code>dnsPromises.resolveMx()</code></a></td>\n</tr>\n<tr>\n<td><code>'NAPTR'</code></td>\n<td>Refer to <a href=\"#dns_dnspromises_resolvenaptr_hostname\"><code>dnsPromises.resolveNaptr()</code></a></td>\n</tr>\n<tr>\n<td><code>'NS'</code></td>\n<td><code>value</code></td>\n</tr>\n<tr>\n<td><code>'PTR'</code></td>\n<td><code>value</code></td>\n</tr>\n<tr>\n<td><code>'SOA'</code></td>\n<td>Refer to <a href=\"#dns_dnspromises_resolvesoa_hostname\"><code>dnsPromises.resolveSoa()</code></a></td>\n</tr>\n<tr>\n<td><code>'SRV'</code></td>\n<td>Refer to <a href=\"#dns_dnspromises_resolvesrv_hostname\"><code>dnsPromises.resolveSrv()</code></a></td>\n</tr>\n<tr>\n<td><code>'TXT'</code></td>\n<td>This type of record contains an array property called <code>entries</code> which refers to <a href=\"#dns_dnspromises_resolvetxt_hostname\"><code>dnsPromises.resolveTxt()</code></a>, e.g. <code>{ entries: ['...'], type: 'TXT' }</code></td>\n</tr>\n</tbody>\n</table>\n<p>Here is an example of the result object:</p>\n<!-- eslint-disable semi -->\n<pre><code class=\"language-js\">[ { type: 'A', address: '127.0.0.1', ttl: 299 },\n { type: 'CNAME', value: 'example.com' },\n { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 },\n { type: 'NS', value: 'ns1.example.com' },\n { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] },\n { type: 'SOA',\n nsname: 'ns1.example.com',\n hostmaster: 'admin.example.com',\n serial: 156696742,\n refresh: 900,\n retry: 900,\n expire: 1800,\n minttl: 60 } ]\n</code></pre>", "type": "module", "displayName": "`dnsPromises.resolveAny(hostname)`" }, { "textRaw": "`dnsPromises.resolveCname(hostname)`", "name": "`dnspromises.resolvecname(hostname)`", "meta": { "added": [ "v10.6.0" ], "changes": [] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n</ul>\n<p>Uses the DNS protocol to resolve <code>CNAME</code> records for the <code>hostname</code>. On success,\nthe <code>Promise</code> is resolved with an array of canonical name records available for\nthe <code>hostname</code> (e.g. <code>['bar.example.com']</code>).</p>", "type": "module", "displayName": "`dnsPromises.resolveCname(hostname)`" }, { "textRaw": "`dnsPromises.resolveMx(hostname)`", "name": "`dnspromises.resolvemx(hostname)`", "meta": { "added": [ "v10.6.0" ], "changes": [] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n</ul>\n<p>Uses the DNS protocol to resolve mail exchange records (<code>MX</code> records) for the\n<code>hostname</code>. On success, the <code>Promise</code> is resolved with an array of objects\ncontaining both a <code>priority</code> and <code>exchange</code> property (e.g.\n<code>[{priority: 10, exchange: 'mx.example.com'}, ...]</code>).</p>", "type": "module", "displayName": "`dnsPromises.resolveMx(hostname)`" }, { "textRaw": "`dnsPromises.resolveNaptr(hostname)`", "name": "`dnspromises.resolvenaptr(hostname)`", "meta": { "added": [ "v10.6.0" ], "changes": [] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n</ul>\n<p>Uses the DNS protocol to resolve regular expression based records (<code>NAPTR</code>\nrecords) for the <code>hostname</code>. On success, the <code>Promise</code> is resolved with an array\nof objects with the following properties:</p>\n<ul>\n<li><code>flags</code></li>\n<li><code>service</code></li>\n<li><code>regexp</code></li>\n<li><code>replacement</code></li>\n<li><code>order</code></li>\n<li><code>preference</code></li>\n</ul>\n<!-- eslint-skip -->\n<pre><code class=\"language-js\">{\n flags: 's',\n service: 'SIP+D2U',\n regexp: '',\n replacement: '_sip._udp.example.com',\n order: 30,\n preference: 100\n}\n</code></pre>", "type": "module", "displayName": "`dnsPromises.resolveNaptr(hostname)`" }, { "textRaw": "`dnsPromises.resolveNs(hostname)`", "name": "`dnspromises.resolvens(hostname)`", "meta": { "added": [ "v10.6.0" ], "changes": [] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n</ul>\n<p>Uses the DNS protocol to resolve name server records (<code>NS</code> records) for the\n<code>hostname</code>. On success, the <code>Promise</code> is resolved with an array of name server\nrecords available for <code>hostname</code> (e.g.\n<code>['ns1.example.com', 'ns2.example.com']</code>).</p>", "type": "module", "displayName": "`dnsPromises.resolveNs(hostname)`" }, { "textRaw": "`dnsPromises.resolvePtr(hostname)`", "name": "`dnspromises.resolveptr(hostname)`", "meta": { "added": [ "v10.6.0" ], "changes": [] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n</ul>\n<p>Uses the DNS protocol to resolve pointer records (<code>PTR</code> records) for the\n<code>hostname</code>. On success, the <code>Promise</code> is resolved with an array of strings\ncontaining the reply records.</p>", "type": "module", "displayName": "`dnsPromises.resolvePtr(hostname)`" }, { "textRaw": "`dnsPromises.resolveSoa(hostname)`", "name": "`dnspromises.resolvesoa(hostname)`", "meta": { "added": [ "v10.6.0" ], "changes": [] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n</ul>\n<p>Uses the DNS protocol to resolve a start of authority record (<code>SOA</code> record) for\nthe <code>hostname</code>. On success, the <code>Promise</code> is resolved with an object with the\nfollowing properties:</p>\n<ul>\n<li><code>nsname</code></li>\n<li><code>hostmaster</code></li>\n<li><code>serial</code></li>\n<li><code>refresh</code></li>\n<li><code>retry</code></li>\n<li><code>expire</code></li>\n<li><code>minttl</code></li>\n</ul>\n<!-- eslint-skip -->\n<pre><code class=\"language-js\">{\n nsname: 'ns.example.com',\n hostmaster: 'root.example.com',\n serial: 2013101809,\n refresh: 10000,\n retry: 2400,\n expire: 604800,\n minttl: 3600\n}\n</code></pre>", "type": "module", "displayName": "`dnsPromises.resolveSoa(hostname)`" }, { "textRaw": "`dnsPromises.resolveSrv(hostname)`", "name": "`dnspromises.resolvesrv(hostname)`", "meta": { "added": [ "v10.6.0" ], "changes": [] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n</ul>\n<p>Uses the DNS protocol to resolve service records (<code>SRV</code> records) for the\n<code>hostname</code>. On success, the <code>Promise</code> is resolved with an array of objects with\nthe following properties:</p>\n<ul>\n<li><code>priority</code></li>\n<li><code>weight</code></li>\n<li><code>port</code></li>\n<li><code>name</code></li>\n</ul>\n<!-- eslint-skip -->\n<pre><code class=\"language-js\">{\n priority: 10,\n weight: 5,\n port: 21223,\n name: 'service.example.com'\n}\n</code></pre>", "type": "module", "displayName": "`dnsPromises.resolveSrv(hostname)`" }, { "textRaw": "`dnsPromises.resolveTxt(hostname)`", "name": "`dnspromises.resolvetxt(hostname)`", "meta": { "added": [ "v10.6.0" ], "changes": [] }, "desc": "<ul>\n<li><code>hostname</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n</ul>\n<p>Uses the DNS protocol to resolve text queries (<code>TXT</code> records) for the\n<code>hostname</code>. On success, the <code>Promise</code> is resolved with a two-dimensional array\nof the text records available for <code>hostname</code> (e.g.\n<code>[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]</code>). Each sub-array contains TXT chunks of\none record. Depending on the use case, these could be either joined together or\ntreated separately.</p>", "type": "module", "displayName": "`dnsPromises.resolveTxt(hostname)`" }, { "textRaw": "`dnsPromises.reverse(ip)`", "name": "`dnspromises.reverse(ip)`", "meta": { "added": [ "v10.6.0" ], "changes": [] }, "desc": "<ul>\n<li><code>ip</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string></a></li>\n</ul>\n<p>Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an\narray of hostnames.</p>\n<p>On error, the <code>Promise</code> is rejected with an <a href=\"errors.html#errors_class_error\"><code>Error</code></a> object, where <code>err.code</code>\nis one of the <a href=\"#dns_error_codes\">DNS error codes</a>.</p>", "type": "module", "displayName": "`dnsPromises.reverse(ip)`" }, { "textRaw": "`dnsPromises.setServers(servers)`", "name": "`dnspromises.setservers(servers)`", "meta": { "added": [ "v10.6.0" ], "changes": [] }, "desc": "<ul>\n<li><code>servers</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\"><string[]></a> array of <a href=\"https://tools.ietf.org/html/rfc5952#section-6\">rfc5952</a> formatted addresses</li>\n</ul>\n<p>Sets the IP address and port of servers to be used when performing DNS\nresolution. The <code>servers</code> argument is an array of <a href=\"https://tools.ietf.org/html/rfc5952#section-6\">rfc5952</a> formatted\naddresses. If the port is the IANA default DNS port (53) it can be omitted.</p>\n<pre><code class=\"language-js\">dnsPromises.setServers([\n '4.4.4.4',\n '[2001:4860:4860::8888]',\n '4.4.4.4:1053',\n '[2001:4860:4860::8888]:1053'\n]);\n</code></pre>\n<p>An error will be thrown if an invalid address is provided.</p>\n<p>The <code>dnsPromises.setServers()</code> method must not be called while a DNS query is in\nprogress.</p>\n<p>Note that this method works much like\n<a href=\"http://man7.org/linux/man-pages/man5/resolv.conf.5.html\">resolve.conf</a>.\nThat is, if attempting to resolve with the first server provided results in a\n<code>NOTFOUND</code> error, the <code>resolve()</code> method will <em>not</em> attempt to resolve with\nsubsequent servers provided. Fallback DNS servers will only be used if the\nearlier ones time out or result in some other error.</p>", "type": "module", "displayName": "`dnsPromises.setServers(servers)`" } ], "type": "module", "displayName": "DNS Promises API" }, { "textRaw": "Error codes", "name": "error_codes", "desc": "<p>Each DNS query can return one of the following error codes:</p>\n<ul>\n<li><code>dns.NODATA</code>: DNS server returned answer with no data.</li>\n<li><code>dns.FORMERR</code>: DNS server claims query was misformatted.</li>\n<li><code>dns.SERVFAIL</code>: DNS server returned general failure.</li>\n<li><code>dns.NOTFOUND</code>: Domain name not found.</li>\n<li><code>dns.NOTIMP</code>: DNS server does not implement requested operation.</li>\n<li><code>dns.REFUSED</code>: DNS server refused query.</li>\n<li><code>dns.BADQUERY</code>: Misformatted DNS query.</li>\n<li><code>dns.BADNAME</code>: Misformatted hostname.</li>\n<li><code>dns.BADFAMILY</code>: Unsupported address family.</li>\n<li><code>dns.BADRESP</code>: Misformatted DNS reply.</li>\n<li><code>dns.CONNREFUSED</code>: Could not contact DNS servers.</li>\n<li><code>dns.TIMEOUT</code>: Timeout while contacting DNS servers.</li>\n<li><code>dns.EOF</code>: End of file.</li>\n<li><code>dns.FILE</code>: Error reading file.</li>\n<li><code>dns.NOMEM</code>: Out of memory.</li>\n<li><code>dns.DESTRUCTION</code>: Channel is being destroyed.</li>\n<li><code>dns.BADSTR</code>: Misformatted string.</li>\n<li><code>dns.BADFLAGS</code>: Illegal flags specified.</li>\n<li><code>dns.NONAME</code>: Given hostname is not numeric.</li>\n<li><code>dns.BADHINTS</code>: Illegal hints flags specified.</li>\n<li><code>dns.NOTINITIALIZED</code>: c-ares library initialization not yet performed.</li>\n<li><code>dns.LOADIPHLPAPI</code>: Error loading <code>iphlpapi.dll</code>.</li>\n<li><code>dns.ADDRGETNETWORKPARAMS</code>: Could not find <code>GetNetworkParams</code> function.</li>\n<li><code>dns.CANCELLED</code>: DNS query cancelled.</li>\n</ul>", "type": "module", "displayName": "Error codes" }, { "textRaw": "Implementation considerations", "name": "implementation_considerations", "desc": "<p>Although <a href=\"#dns_dns_lookup_hostname_options_callback\"><code>dns.lookup()</code></a> and the various <code>dns.resolve*()/dns.reverse()</code>\nfunctions have the same goal of associating a network name with a network\naddress (or vice versa), their behavior is quite different. These differences\ncan have subtle but significant consequences on the behavior of Node.js\nprograms.</p>", "modules": [ { "textRaw": "`dns.lookup()`", "name": "`dns.lookup()`", "desc": "<p>Under the hood, <a href=\"#dns_dns_lookup_hostname_options_callback\"><code>dns.lookup()</code></a> uses the same operating system facilities\nas most other programs. For instance, <a href=\"#dns_dns_lookup_hostname_options_callback\"><code>dns.lookup()</code></a> will almost always\nresolve a given name the same way as the <code>ping</code> command. On most POSIX-like\noperating systems, the behavior of the <a href=\"#dns_dns_lookup_hostname_options_callback\"><code>dns.lookup()</code></a> function can be\nmodified by changing settings in <a href=\"http://man7.org/linux/man-pages/man5/nsswitch.conf.5.html\"><code>nsswitch.conf(5)</code></a> and/or <a href=\"http://man7.org/linux/man-pages/man5/resolv.conf.5.html\"><code>resolv.conf(5)</code></a>,\nbut note that changing these files will change the behavior of <em>all other\nprograms running on the same operating system</em>.</p>\n<p>Though the call to <code>dns.lookup()</code> will be asynchronous from JavaScript's\nperspective, it is implemented as a synchronous call to <a href=\"http://man7.org/linux/man-pages/man3/getaddrinfo.3.html\"><code>getaddrinfo(3)</code></a> that runs\non libuv's threadpool. This can have surprising negative performance\nimplications for some applications, see the <a href=\"cli.html#cli_uv_threadpool_size_size\"><code>UV_THREADPOOL_SIZE</code></a>\ndocumentation for more information.</p>\n<p>Note that various networking APIs will call <code>dns.lookup()</code> internally to resolve\nhost names. If that is an issue, consider resolving the hostname to an address\nusing <code>dns.resolve()</code> and using the address instead of a host name. Also, some\nnetworking APIs (such as <a href=\"net.html#net_socket_connect_options_connectlistener\"><code>socket.connect()</code></a> and <a href=\"dgram.html#dgram_dgram_createsocket_options_callback\"><code>dgram.createSocket()</code></a>)\nallow the default resolver, <code>dns.lookup()</code>, to be replaced.</p>", "type": "module", "displayName": "`dns.lookup()`" }, { "textRaw": "`dns.resolve()`, `dns.resolve*()` and `dns.reverse()`", "name": "`dns.resolve()`,_`dns.resolve*()`_and_`dns.reverse()`", "desc": "<p>These functions are implemented quite differently than <a href=\"#dns_dns_lookup_hostname_options_callback\"><code>dns.lookup()</code></a>. They\ndo not use <a href=\"http://man7.org/linux/man-pages/man3/getaddrinfo.3.html\"><code>getaddrinfo(3)</code></a> and they <em>always</em> perform a DNS query on the\nnetwork. This network communication is always done asynchronously, and does not\nuse libuv's threadpool.</p>\n<p>As a result, these functions cannot have the same negative impact on other\nprocessing that happens on libuv's threadpool that <a href=\"#dns_dns_lookup_hostname_options_callback\"><code>dns.lookup()</code></a> can have.</p>\n<p>They do not use the same set of configuration files than what <a href=\"#dns_dns_lookup_hostname_options_callback\"><code>dns.lookup()</code></a>\nuses. For instance, <em>they do not use the configuration from <code>/etc/hosts</code></em>.</p>", "type": "module", "displayName": "`dns.resolve()`, `dns.resolve*()` and `dns.reverse()`" } ], "type": "module", "displayName": "Implementation considerations" } ], "type": "module", "displayName": "DNS" } ] }