Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

DNS NAPTR, targets #3177 #4033

Closed
wants to merge 3 commits into from

4 participants

@langpavel

Test not working, probably sip.voice.google.com has no NAPTR record?

Can anybody take valid NAPTR query into test?

targets #3177, #3170

@johntdyer, @ssuda can test this?

@saghul

You can use the sip2sip.info domain.

 dig -t naptr sip2sip.info

; <<>> DiG 9.6-ESV-R4-P3 <<>> -t naptr sip2sip.info
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43840
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 3, ADDITIONAL: 2

;; QUESTION SECTION:
;sip2sip.info.                  IN      NAPTR

;; ANSWER SECTION:
sip2sip.info.           3600    IN      NAPTR   30 100 "s" "SIP+D2U" "" _sip._udp.sip2sip.info.
sip2sip.info.           3600    IN      NAPTR   10 100 "s" "SIP+D2T" "" _sip._tcp.sip2sip.info.
sip2sip.info.           3600    IN      NAPTR   20 100 "s" "SIPS+D2T" "" _sips._tcp.sip2sip.info.

;; AUTHORITY SECTION:
sip2sip.info.           9828    IN      NS      ns7.dns-hosting.info.
sip2sip.info.           9828    IN      NS      ns1.dns-hosting.info.
sip2sip.info.           9828    IN      NS      ns2.dns-hosting.info.

;; ADDITIONAL SECTION:
ns1.dns-hosting.info.   251     IN      A       81.23.228.131
_sip._udp.sip2sip.info. 1974    IN      SRV     100 100 5060 proxy.sipthor.net.

;; Query time: 44 msec
;; SERVER: 192.168.99.101#53(192.168.99.101)
;; WHEN: Wed Oct 24 23:40:42 2012
;; MSG SIZE  rcvd: 304
@langpavel

Working, still can be merged without conflicts.
Can someone review? @bnoordhuis @isaacs?

@isaacs

This looks good to me. (Should be squashed into one commit, but I can do that easily enough.)

I'd like to get #4933 in first, though.

@indutny
Owner

LGTM, squashed and landed as 2ad9872 (with some small style fixes).

@indutny indutny closed this
@isaacs isaacs referenced this pull request
Closed

DNS: Support NAPTR queries #3170

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 18, 2012
  1. @langpavel

    DNS: Support NAPTR queries

    langpavel authored
    This reverts commit a90bc78.
  2. @langpavel

    Typecasts

    langpavel authored
Commits on Oct 25, 2012
  1. @langpavel

    test DNS NAPTR working

    langpavel authored
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
@@ -605,6 +605,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(reinterpret_cast<char*>(naptr_current->flags)));
+ naptr_record->Set(service_symbol, String::New(reinterpret_cast<char*>(naptr_current->service)));
+ naptr_record->Set(regexp_symbol, String::New(reinterpret_cast<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));
+
+ naptr_records->Set(Integer::New(i++), naptr_record);
+ }
+
+ ares_free_data(naptr_start);
+
+ this->CallOnComplete(naptr_records);
+ }
+};
+
class GetHostByAddrWrap: public QueryWrap {
public:
@@ -882,6 +937,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('sip2sip.info', 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.