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