From c5367283350d54b7bcf5cf59d1e2e8b91255f2a4 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 28 Oct 2009 23:02:52 +0100 Subject: [PATCH] Move node.dns.* into /dns.js --- doc/api.txt | 30 +++++++++++++++++------------- test/mjsunit/disabled/test_dns.js | 6 ++++-- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/doc/api.txt b/doc/api.txt index 9d4d0d7680..b56324635d 100644 --- a/doc/api.txt +++ b/doc/api.txt @@ -1199,13 +1199,17 @@ Disables the Nagle algorithm. By default TCP connections use the Nagle algorithm, they buffer data before sending it off. Setting +noDelay+ will immediately fire off data each time +connection.send()+ is called. -=== DNS +=== DNS module + +Use +require("/dns.js")+ to access this module Here is an example of which resolves +"www.google.com"+ then reverse resolves the IP addresses which are returned. ------------------------------------------------------------------------- -var resolution = node.dns.resolve4("www.google.com"); +var dns = require("/dns.js"); + +var resolution = dns.resolve4("www.google.com"); resolution.addCallback(function (addresses, ttl, cname) { puts("addresses: " + JSON.stringify(addresses)); @@ -1214,7 +1218,7 @@ resolution.addCallback(function (addresses, ttl, cname) { for (var i = 0; i < addresses.length; i++) { var a = addresses[i]; - var reversing = node.dns.reverse(a); + var reversing = dns.reverse(a); reversing.addCallback( function (domains, ttl, cname) { puts("reverse for " + a + ": " + JSON.stringify(domains)); }); @@ -1230,7 +1234,7 @@ resolution.addErrback(function (code, msg) { ------------------------------------------------------------------------- -+node.dns.resolve4(domain)+:: ++dns.resolve4(domain)+:: Resolves a domain (e.g. +"google.com"+) into an array of IPv4 addresses (e.g. +["74.125.79.104", "74.125.79.105", "74.125.79.106"]+). @@ -1241,11 +1245,11 @@ This function returns a promise. - on error: returns +code, msg+. +code+ is one of the error codes listed below and +msg+ is a string describing the error in English. -+node.dns.resolve6(domain)+:: ++dns.resolve6(domain)+:: -The same as +node.dns.resolve4()+ except for IPv6 queries (an +AAAA+ query). +The same as +dns.resolve4()+ except for IPv6 queries (an +AAAA+ query). -+node.dns.reverse(ip)+:: ++dns.reverse(ip)+:: Reverse resolves an ip address to an array of domain names. @@ -1258,12 +1262,12 @@ Reverse resolves an ip address to an array of domain names. Each DNS query can return an error code. -- +node.dns.TEMPFAIL+: timeout, SERVFAIL or similar. -- +node.dns.PROTOCOL+: got garbled reply. -- +node.dns.NXDOMAIN+: domain does not exists. -- +node.dns.NODATA+: domain exists but no data of reqd type. -- +node.dns.NOMEM+: out of memory while processing. -- +node.dns.BADQUERY+: the query is malformed. +- +dns.TEMPFAIL+: timeout, SERVFAIL or similar. +- +dns.PROTOCOL+: got garbled reply. +- +dns.NXDOMAIN+: domain does not exists. +- +dns.NODATA+: domain exists but no data of reqd type. +- +dns.NOMEM+: out of memory while processing. +- +dns.BADQUERY+: the query is malformed. diff --git a/test/mjsunit/disabled/test_dns.js b/test/mjsunit/disabled/test_dns.js index ccfcf00abe..352643a89a 100644 --- a/test/mjsunit/disabled/test_dns.js +++ b/test/mjsunit/disabled/test_dns.js @@ -1,8 +1,10 @@ node.mixin(require("../common.js")); +var dns = require("/dns.js"); + for (var i = 2; i < ARGV.length; i++) { var name = ARGV[i] puts("looking up " + name); - var resolution = node.dns.resolve4(name); + var resolution = dns.resolve4(name); resolution.addCallback(function (addresses, ttl, cname) { puts("addresses: " + JSON.stringify(addresses)); @@ -11,7 +13,7 @@ for (var i = 2; i < ARGV.length; i++) { for (var i = 0; i < addresses.length; i++) { var a = addresses[i]; - var reversing = node.dns.reverse(a); + var reversing = dns.reverse(a); reversing.addCallback( function (domains, ttl, cname) { puts("reverse for " + a + ": " + JSON.stringify(domains)); });