Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save koichik/939141 to your computer and use it in GitHub Desktop.

Select an option

Save koichik/939141 to your computer and use it in GitHub Desktop.
Fix dns.resolve() with 'PTR' throws Error: Unknown type "PTR"
From 8eab2f26a8e9d27ca10314fb1dc7535e555f096c Mon Sep 17 00:00:00 2001
From: koichik <koichik@improvement.jp>
Date: Sun, 24 Apr 2011 08:56:11 +0900
Subject: [PATCH 1/2] Fix dns.resolve() with 'PTR' throws Error: Unknown type "PTR"
---
lib/dns.js | 2 +-
test/simple/test-c-ares.js | 6 ++++++
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/lib/dns.js b/lib/dns.js
index a71738e..3ee997b 100644
--- a/lib/dns.js
+++ b/lib/dns.js
@@ -247,7 +247,7 @@ var resolveMap = { A: exports.resolve4,
MX: exports.resolveMx,
TXT: exports.resolveTxt,
SRV: exports.resolveSrv,
- PTR: exports.resolvePtr,
+ PTR: exports.reverse,
NS: exports.resolveNs,
CNAME: exports.resolveCname };
diff --git a/test/simple/test-c-ares.js b/test/simple/test-c-ares.js
index 1f68c53..f70e9b1 100644
--- a/test/simple/test-c-ares.js
+++ b/test/simple/test-c-ares.js
@@ -58,3 +58,9 @@ dns.lookup('ipv6.google.com', function(error, result, addressType) {
//assert.equal('string', typeof result);
assert.equal(6, addressType);
});
+
+dns.resolve('127.0.0.1', 'PTR', function(error, domains) {
+ if (error) throw error;
+ assert.equal(domains.length, 1);
+ assert.equal(domains[0], 'localhost');
+});
--
1.7.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment