|
|
@ -1590,85 +1590,84 @@ resolves the IP addresses which are returned. |
|
|
|
var dns = require("dns"), |
|
|
|
sys = require("sys"); |
|
|
|
|
|
|
|
var resolution = dns.resolve4("www.google.com"); |
|
|
|
dns.resolve4("www.google.com", function (err, addresses, ttl, cname) { |
|
|
|
if (err) throw err; |
|
|
|
|
|
|
|
resolution.addCallback(function (addresses, ttl, cname) { |
|
|
|
sys.puts("addresses: " + JSON.stringify(addresses)); |
|
|
|
sys.puts("ttl: " + JSON.stringify(ttl)); |
|
|
|
sys.puts("cname: " + JSON.stringify(cname)); |
|
|
|
|
|
|
|
for (var i = 0; i < addresses.length; i++) { |
|
|
|
var a = addresses[i]; |
|
|
|
var reversing = dns.reverse(a); |
|
|
|
reversing.addCallback( function (domains, ttl, cname) { |
|
|
|
sys.puts("reverse for " + a + ": " + JSON.stringify(domains)); |
|
|
|
}); |
|
|
|
reversing.addErrback( function (e) { |
|
|
|
puts("reverse for " + a + " failed: " + e.message); |
|
|
|
dns.reverse(a, function (err, domains, ttl, cname) { |
|
|
|
if (err) { |
|
|
|
puts("reverse for " + a + " failed: " + e.message); |
|
|
|
} else { |
|
|
|
sys.puts("reverse for " + a + ": " + JSON.stringify(domains)); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
resolution.addErrback(function (e) { |
|
|
|
puts("error: " + e.message); |
|
|
|
}); |
|
|
|
------------------------------------------------------------------------- |
|
|
|
|
|
|
|
+dns.resolve(domain, rrtype = 'A')+:: |
|
|
|
+dns.resolve(domain, rrtype = 'A', callback)+:: |
|
|
|
|
|
|
|
Resolves a domain (e.g. +"google.com"+) into an array of the record types |
|
|
|
specified by rrtype. Valid rrtypes are +A+ (IPV4 addresses), +AAAA+ (IPV6 |
|
|
|
addresses), +MX+ (mail exchange records), +TXT+ (text records), +SRV+ |
|
|
|
(SRV records), and +PTR+ (used for reverse IP lookups). |
|
|
|
This function returns a promise. |
|
|
|
- on success: returns +addresses, ttl, cname+. +ttl+ (time-to-live) is an integer |
|
|
|
specifying the number of seconds this result is valid for. +cname+ is the |
|
|
|
canonical name for the query. |
|
|
|
The type of each item in +addresses+ is determined by the record type, and |
|
|
|
described in the documentation for the corresponding lookup methods below. |
|
|
|
- on error: Returns an instanceof Error object, where the "errno" field is one |
|
|
|
of the error codes listed below and the "message" field is a string |
|
|
|
describing the error in English. |
|
|
|
|
|
|
|
+dns.resolve4(domain)+:: |
|
|
|
+ |
|
|
|
The callback has arguments +(err, addresses, ttl, cname)+. +ttl+ |
|
|
|
(time-to-live) is an integer specifying the number of seconds this result is |
|
|
|
valid for. +cname+ is the canonical name for the query. The type of each |
|
|
|
item in +addresses+ is determined by the record type, and |
|
|
|
described in the documentation for the corresponding lookup methods below. |
|
|
|
+ |
|
|
|
On error, +err+ would be an instanceof +Error+ object, where +err.errno+ is |
|
|
|
one of the error codes listed below and +err.message+ is a string describing |
|
|
|
the error in English. |
|
|
|
|
|
|
|
|
|
|
|
+dns.resolve4(domain, callback)+:: |
|
|
|
|
|
|
|
The same as +dns.resolve()+, but only for IPv4 queries (+A+ records). |
|
|
|
+addresses+ is an array of IPv4 addresses (e.g. +["74.125.79.104", |
|
|
|
"74.125.79.105", "74.125.79.106"]+). |
|
|
|
|
|
|
|
+dns.resolve6(domain)+:: |
|
|
|
+dns.resolve6(domain, callback)+:: |
|
|
|
|
|
|
|
The same as +dns.resolve4()+ except for IPv6 queries (an +AAAA+ query). |
|
|
|
|
|
|
|
+dns.resolveMx(domain)+:: |
|
|
|
|
|
|
|
+dns.resolveMx(domain, callback)+:: |
|
|
|
|
|
|
|
The same as +dns.resolve()+, but only for mail exchange queries (+MX+ records). |
|
|
|
+addresses+ is an array of MX records, each with a priority and an exchange |
|
|
|
attribute (e.g. +[{"priority": 10, "exchange": "mx.example.com"},...]+). |
|
|
|
|
|
|
|
+dns.resolveTxt(domain)+:: |
|
|
|
+dns.resolveTxt(domain, callback)+:: |
|
|
|
|
|
|
|
The same as +dns.resolve()+, but only for text queries (+TXT+ records). |
|
|
|
+addresses+ is an array of the text records available for +domain+ (e.g., |
|
|
|
+["v=spf1 ip4:0.0.0.0 ~all"]+). |
|
|
|
|
|
|
|
+dns.resolveSrv(domain)+:: |
|
|
|
+dns.resolveSrv(domain, callback)+:: |
|
|
|
|
|
|
|
The same as +dns.resolve()+, but only for service records (+SRV+ records). |
|
|
|
+addresses+ is an array of the SRV records available for +domain+. Properties |
|
|
|
of SRV records are priority, weight, port, and name (e.g., +[{"priority": 10, |
|
|
|
{"weight": 5, "port": 21223, "name": "service.example.com"}, ...]+). |
|
|
|
|
|
|
|
+dns.reverse(ip)+:: |
|
|
|
+dns.reverse(ip, callback)+:: |
|
|
|
|
|
|
|
Reverse resolves an ip address to an array of domain names. |
|
|
|
|
|
|
|
- on success: returns +domains, ttl, cname+. +ttl+ (time-to-live) is an integer |
|
|
|
specifying the number of seconds this result is valid for. +cname+ is the |
|
|
|
canonical name for the query. +domains+ is an array of domains. |
|
|
|
- on error: Returns an instanceof Error object, where the "errno" field is one |
|
|
|
of the error codes listed below and the "message" field is a string |
|
|
|
describing the error in English. |
|
|
|
+ |
|
|
|
The callback has arguments +(err, domains, ttl, cname)+. +ttl+ (time-to-live) is an integer |
|
|
|
specifying the number of seconds this result is valid for. +cname+ is the |
|
|
|
canonical name for the query. +domains+ is an array of domains. |
|
|
|
+ |
|
|
|
If there an an error, +err+ will be non-null and an instanceof the Error |
|
|
|
object. |
|
|
|
|
|
|
|
|
|
|
|
Each DNS query can return an error code. |
|
|
@ -1680,6 +1679,7 @@ Each DNS query can return an error code. |
|
|
|
- +dns.NOMEM+: out of memory while processing. |
|
|
|
- +dns.BADQUERY+: the query is malformed. |
|
|
|
|
|
|
|
|
|
|
|
== Assert Module |
|
|
|
|
|
|
|
This module is used for writing unit tests for your applications, you can access it with +require("assert")+. |
|
|
|