-
Notifications
You must be signed in to change notification settings - Fork 31.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dns: add resolveAny support #13137
Closed
Closed
dns: add resolveAny support #13137
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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). | ||
|
@@ -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 all records (also known as `ANY` or `*` query). | ||
The `ret` argument passed to the `callback` function will be an array containing | ||
various types of records. Each object has a property `type` that indicates the | ||
type of the current record. And depending on the `type`, additional properties | ||
will be present on the object: | ||
|
||
| 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-like object with `length` and `indexes`, eg. `{'0':'sth','length':1}` | | ||
|
||
Here is a example of the `ret` object passed to the callback: | ||
|
||
<!-- eslint-disable --> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
```js | ||
[ { type: 'A', address: '127.0.0.1', ttl: 299 }, | ||
{ type: 'CNAME', value: 'example.com' }, | ||
{ type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 }, | ||
{ type: 'NS', value: 'ns1.example.com', type: 'NS' }, | ||
{ type: 'TXT', '0': 'v=spf1 include:_spf.example.com ~all', length: 1 }, | ||
{ type: 'SOA', | ||
nsname: 'ns1.example.com', | ||
hostmaster: 'admin.example.com', | ||
serial: 156696742, | ||
refresh: 900, | ||
retry: 900, | ||
expire: 1800, | ||
minttl: 60 } ] | ||
``` | ||
|
||
## dns.reverse(ip, callback) | ||
<!-- YAML | ||
added: v0.1.16 | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.