Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions doc/api/dns.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ records. The type and structure of individual results varies based on `rrtype`:
| `'SOA'` | start of authority records | {Object} | [`dns.resolveSoa()`][] |
| `'SRV'` | service records | {Object} | [`dns.resolveSrv()`][] |
| `'TXT'` | text records | {string} | [`dns.resolveTxt()`][] |
| `'ANY'` | any records | {Object} | [`dns.resolveAny()`][] |

On error, `err` is an [`Error`][] object, where `err.code` is one of the
[DNS error codes](#dns_error_codes).
Expand Down Expand Up @@ -417,6 +418,51 @@ is a two-dimensional array of the text records available for `hostname` (e.g.,
one record. Depending on the use case, these could be either joined together or
treated separately.

## dns.resolveAny(hostname, callback)

- `hostname` {string}
- `callback` {Function}
- `err` {Error}
- `ret` {Object[][]}

Uses the DNS protocol to resolve any queries (`ANY` records) for the `hostname`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"to resolve all records (also known as ANY or * query)"

(This is taken out of the rfc - 255 A request for all records)

The `ret` argument passed to the `callback` function will be an array of objects
with uncertain type of records. Each object has a property `type` that indicates
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by uncertain? That the records are not homogenous?

Copy link
Contributor Author

@XadillaX XadillaX May 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Their columns properties are not the same.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, how about an array containing various types of records then?

Copy link
Contributor Author

@XadillaX XadillaX May 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌 ヘ|・∀・|ノ*~●

the type of current record. And for each type of record, the object structure
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe replace the last sentence with: "Depending on the type, additional properties will be present on the object:

will be like:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the table to illustrate the structure is a bit unclear.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using list? or something else?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure... the table may be ok if the sentence leading into it is changed up a bit. Not having any specific ideas on how to improve it tho. It just reads a bit awkward.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm... So I gave an example following.

| Type | Properties |
|------|------------|
| `"A"` | `address` / `ttl` |
| `"AAAA"` | `address` / `ttl` |
| `"CNAME"` | `value` |
| `"MX"` | Refer to [`dns.resolveMx()`][] |
| `"NAPTR"` | Refer to [`dns.resolveNaptr()`][] |
| `"NS"` | `value` |
| `"PTR"` | `value` |
| `"SOA"` | Refer to [`dns.resolveSoa()`][] |
| `"SRV"` | Refer to [`dns.resolveSrv()`][] |
| `"TXT"` | This is an array-liked object with `length` and `indexes`, eg. `{'0':'sth','length':1}` |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not return a regular array (e.g. where Array.isArray(array) returns true)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we need the extra column type.

You mean create an array with extra type directly?

eg.

const arr = [ 'foo', 'bar' ];
arr.type = 'TXT';

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, seems reasonable to keep it that way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: array-like

I think this should be an array; if necessary, you can make it an entries: […] property on the object itself.


Following is a example of the `ret` object passed to the callback:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Here is ..." might be better


<!-- eslint-disable -->
Copy link
Member

@addaleax addaleax May 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn’t there be a corresponding eslint-enable comment? probably not, looking at other docs. 😄

```js
[ { address: '127.0.0.1', ttl: 299, type: 'A' },
{ value: 'example.com', type: 'CNAME' }, // in fact, CNAME can't stay with A
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe remove this comment, while correct, it seems unrelated here.

{ exchange: 'alt4.aspmx.l.example.com', priority: 50, type: 'MX' },
{ value: 'ns1.example.com', type: 'NS' },
{ '0': 'v=spf1 include:_spf.example.com ~all', type: 'TXT', length: 1 },
{ nsname: 'ns1.example.com',
hostmaster: 'admin.example.com',
serial: 156696742,
refresh: 900,
retry: 900,
expire: 1800,
minttl: 60,
type: 'SOA' } ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you structure this example to type is sorted first in each object?

```

## dns.reverse(ip, callback)
<!-- YAML
added: v0.1.16
Expand Down Expand Up @@ -531,6 +577,7 @@ uses. For instance, _they do not use the configuration from `/etc/hosts`_.
[`dns.resolveSoa()`]: #dns_dns_resolvesoa_hostname_callback
[`dns.resolveSrv()`]: #dns_dns_resolvesrv_hostname_callback
[`dns.resolveTxt()`]: #dns_dns_resolvetxt_hostname_callback
[`dns.resolveAny()`]: #dns_dns_resolveany_hostname_callback
[DNS error codes]: #dns_error_codes
[Implementation considerations section]: #dns_implementation_considerations
[supported `getaddrinfo` flags]: #dns_supported_getaddrinfo_flags
Expand Down
2 changes: 2 additions & 0 deletions lib/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ function resolver(bindingName) {


var resolveMap = Object.create(null);
resolveMap.ANY = resolver('queryAny');
resolveMap.A = resolver('queryA');
resolveMap.AAAA = resolver('queryAaaa');
resolveMap.CNAME = resolver('queryCname');
Expand Down Expand Up @@ -361,6 +362,7 @@ module.exports = {
getServers,
setServers,
resolve,
resolveAny: resolveMap.ANY,
resolve4: resolveMap.A,
resolve6: resolveMap.AAAA,
resolveCname: resolveMap.CNAME,
Expand Down
Loading