Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

DNS: Support NAPTR queries #3177

Closed
wants to merge 1 commit into from

4 participants

@ssuda

Adding support for NAPTR records
fixes #3170

src/cares_wrap.cc
@@ -485,6 +485,63 @@ class QuerySrvWrap: public QueryWrap {
}
};
+#if (ARES_VERSION >= 0x010706)

Drop the conditional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
src/cares_wrap.cc
((6 lines not shown))
+ public:
+ int Send(const char* name) {
+ ares_query(ares_channel,
+ name,
+ ns_c_in,
+ ns_t_naptr,
+ Callback,
+ GetQueryArg());
+ return 0;
+ }
+
+ protected:
+ void Parse(unsigned char* buf, int len) {
+ HandleScope scope;
+
+ struct ares_naptr_reply* naptr_start;

Superfluous struct keyword. (Happens down below too).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
src/node.cc
@@ -2082,6 +2082,9 @@ static void ProcessTitleSetter(Local<String> property,
obj->Set(String::NewSymbol("ipv6"), True()); // TODO ping libuv
obj->Set(String::NewSymbol("tls_npn"), Boolean::New(use_npn));
obj->Set(String::NewSymbol("tls_sni"), Boolean::New(use_sni));
+#if (ARES_VERSION >= 0x010706)
+ obj->Set(String::NewSymbol("dns_naptr"), True());
+#endif

This can be removed. NAPTR support will be in v0.8.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@bnoordhuis

LGTM in general. This PR depends on a c-ares upgrade in libuv but that will happen soon.

ssuda DNS: Support NAPTR queries
Adding support for NAPTR records
fixes #3170
9dc7341
@ssuda

Updated to include @bnoordhuis comments, Thanks.

@bnoordhuis bnoordhuis was assigned
@isaacs
Owner

Landed on 91bf18f.

Thanks!

@isaacs isaacs closed this
@isaacs
Owner

Whoops, that was premature, sorry. NAPTR support is not landed yet.

Pushing this off until post-0.8. Sorry for the confusion.

Reverted on a90bc78, tagged for post-v0.8.

@isaacs isaacs reopened this
@johntdyer

Any idea when this is going to happen ? Would love to use Node for an intelligent proxy, but I require NAPTR support in order to do it.

@langpavel langpavel referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@isaacs
Owner

It looks like the upgrade to cares is done, but this PR has to be rebased onto master in order to be considered.

I fixed test-internet in #4933, but with this patch on top of that branch, it won't build without this additional patch:

diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc
index 1734a62..5940ec3 100644
--- a/src/cares_wrap.cc
+++ b/src/cares_wrap.cc
@@ -651,9 +651,10 @@ class QueryNaptrWrap: public QueryWrap {

       Local<Object> naptr_record = Object::New();

-      naptr_record->Set(flags_symbol, String::New(naptr_current->flags));
-      naptr_record->Set(service_symbol, String::New(naptr_current->service));
-      naptr_record->Set(regexp_symbol, String::New(naptr_current->regexp));
+      naptr_record->Set(flags_symbol, String::New((const char *)naptr_current->flags));
+      naptr_record->Set(service_symbol, String::New((const char *)naptr_current->service));
+      naptr_record->Set(regexp_symbol, String::New((const char *)naptr_current->regexp));
+
       naptr_record->Set(replacement_symbol, String::New(naptr_current->replacement));
       naptr_record->Set(order_symbol, Integer::New(naptr_current->order));
       naptr_record->Set(preference_symbol, Integer::New(naptr_current->preference));

and the tests don't pass.

I'm closing this PR for now. Please feel free to reincarnate it when those changes are made.

Thanks!

@isaacs isaacs closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 29, 2012
  1. DNS: Support NAPTR queries

    ssuda authored
    Adding support for NAPTR records
    fixes #3170
This page is out of date. Refresh to see the latest.
Showing with 81 additions and 0 deletions.
  1. +1 −0  lib/dns.js
  2. +56 −0 src/cares_wrap.cc
  3. +24 −0 test/internet/test-dns.js
View
1  lib/dns.js
@@ -169,6 +169,7 @@ exports.resolveMx = resolveMap.MX = resolver('queryMx');
exports.resolveNs = resolveMap.NS = resolver('queryNs');
exports.resolveTxt = resolveMap.TXT = resolver('queryTxt');
exports.resolveSrv = resolveMap.SRV = resolver('querySrv');
+exports.resolveNaptr = resolveMap.NAPTR = resolver('queryNaptr');
exports.reverse = resolveMap.PTR = resolver('getHostByAddr');
View
56 src/cares_wrap.cc
@@ -485,6 +485,61 @@ class QuerySrvWrap: public QueryWrap {
}
};
+class QueryNaptrWrap: public QueryWrap {
+ public:
+ int Send(const char* name) {
+ ares_query(ares_channel,
+ name,
+ ns_c_in,
+ ns_t_naptr,
+ Callback,
+ GetQueryArg());
+ return 0;
+ }
+
+ protected:
+ void Parse(unsigned char* buf, int len) {
+ HandleScope scope;
+
+ ares_naptr_reply* naptr_start;
+ int status = ares_parse_naptr_reply(buf, len, &naptr_start);
+
+ if (status != ARES_SUCCESS) {
+ this->ParseError(status);
+ return;
+ }
+
+ Local<Array> naptr_records = Array::New();
+ Local<String> flags_symbol = String::NewSymbol("flags");
+ Local<String> service_symbol = String::NewSymbol("service");
+ Local<String> regexp_symbol = String::NewSymbol("regexp");
+ Local<String> replacement_symbol = String::NewSymbol("replacement");
+ Local<String> order_symbol = String::NewSymbol("order");
+ Local<String> preference_symbol = String::NewSymbol("preference");
+
+ int i = 0;
+ for (ares_naptr_reply* naptr_current = naptr_start;
+ naptr_current;
+ naptr_current = naptr_current->next) {
+
+ Local<Object> naptr_record = Object::New();
+
+ naptr_record->Set(flags_symbol, String::New(naptr_current->flags));
+ naptr_record->Set(service_symbol, String::New(naptr_current->service));
+ naptr_record->Set(regexp_symbol, String::New(naptr_current->regexp));
+ naptr_record->Set(replacement_symbol, String::New(naptr_current->replacement));
+ naptr_record->Set(order_symbol, Integer::New(naptr_current->order));
+ naptr_record->Set(preference_symbol, Integer::New(naptr_current->preference));
+
+ naptr_records->Set(Integer::New(i++), naptr_record);
+ }
+
+ ares_free_data(naptr_start);
+
+ this->CallOnComplete(naptr_records);
+ }
+};
+
class GetHostByAddrWrap: public QueryWrap {
public:
@@ -746,6 +801,7 @@ static void Initialize(Handle<Object> target) {
NODE_SET_METHOD(target, "queryNs", Query<QueryNsWrap>);
NODE_SET_METHOD(target, "queryTxt", Query<QueryTxtWrap>);
NODE_SET_METHOD(target, "querySrv", Query<QuerySrvWrap>);
+ NODE_SET_METHOD(target, "queryNaptr", Query<QueryNaptrWrap>);
NODE_SET_METHOD(target, "getHostByAddr", Query<GetHostByAddrWrap>);
NODE_SET_METHOD(target, "getHostByName", QueryWithFamily<GetHostByNameWrap>);
View
24 test/internet/test-dns.js
@@ -219,6 +219,30 @@ TEST(function test_resolveSrv(done) {
checkWrap(req);
});
+TEST(function test_resolveNaptr(done) {
+ var req = dns.resolveNaptr('sip.voice.google.com', function(err, result) {
+ if (err) throw err;
+
+ assert.ok(result.length > 0);
+
+ for (var i = 0; i < result.length; i++) {
+ var item = result[i];
+ assert.ok(item);
+ assert.ok(typeof item === 'object');
+
+ assert.ok(typeof item.flags === 'string');
+ assert.ok(typeof item.service === 'string');
+ assert.ok(typeof item.regexp === 'string');
+ assert.ok(typeof item.replacement === 'string');
+ assert.ok(typeof item.order === 'number');
+ assert.ok(typeof item.preference === 'number');
+ }
+
+ done();
+ });
+
+ checkWrap(req);
+});
TEST(function test_resolveCname(done) {
var req = dns.resolveCname('www.google.com', function(err, names) {
Something went wrong with that request. Please try again.