diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2016-10-26 07:54:20 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2016-11-18 22:01:44 +0100 |
commit | 6b1a8d03c7a8aabb20568af2e5d07c18c92a4c0c (patch) | |
tree | 0f835fefe0772f7cf926284d6353cc14d8e9bab2 /src/cares_wrap.cc | |
parent | c31b507b947d5b4803dd96a7c9a09fd2112085ab (diff) | |
download | android-node-v8-6b1a8d03c7a8aabb20568af2e5d07c18c92a4c0c.tar.gz android-node-v8-6b1a8d03c7a8aabb20568af2e5d07c18c92a4c0c.tar.bz2 android-node-v8-6b1a8d03c7a8aabb20568af2e5d07c18c92a4c0c.zip |
dns: implement {ttl: true} for dns.resolve6()
Add an option to retrieve the Time-To-Live of the AAAA record.
PR-URL: https://github.com/nodejs/node/pull/9296
Refs: https://github.com/nodejs/node/issues/5893
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Diffstat (limited to 'src/cares_wrap.cc')
-rw-r--r-- | src/cares_wrap.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index 4b9ba26fe4..2b61209f6e 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -440,18 +440,27 @@ class QueryAaaaWrap: public QueryWrap { HandleScope handle_scope(env()->isolate()); Context::Scope context_scope(env()->context()); - struct hostent* host; + hostent* host; + ares_addr6ttl addrttls[256]; + int naddrttls = arraysize(addrttls); - int status = ares_parse_aaaa_reply(buf, len, &host, nullptr, nullptr); + int status = ares_parse_aaaa_reply(buf, len, &host, addrttls, &naddrttls); if (status != ARES_SUCCESS) { ParseError(status); return; } Local<Array> addresses = HostentToAddresses(env(), host); + Local<Array> ttls = Array::New(env()->isolate(), naddrttls); + + auto context = env()->context(); + for (int i = 0; i < naddrttls; i += 1) { + auto value = Integer::New(env()->isolate(), addrttls[i].ttl); + ttls->Set(context, i, value).FromJust(); + } ares_free_hostent(host); - this->CallOnComplete(addresses); + CallOnComplete(addresses, ttls); } }; |