• Home
  • Raw
  • Download

Lines Matching +full:srv +full:- +full:ipv4 +full:- +full:multi +full:- +full:target

24 #include "async_wrap-inl.h"
25 #include "env-inl.h"
26 #include "memory_tracker-inl.h"
28 #include "req_wrap-inl.h"
29 #include "util-inl.h"
90 const int ns_t_cname_or_a = -1;
92 #define DNS_ESETSRVPENDING -1000
140 return std::hash<ares_socket_t>()(a->sock); in operator ()()
146 return a->sock == b->sock; in operator ()()
178 tracker->TrackField("timer_handle", *timer_handle_); in MemoryInfo()
179 tracker->TrackField("task_list", task_list_, "node_ares_task_list"); in MemoryInfo()
217 CHECK(args[0]->IsInt32()); in New()
218 const int timeout = args[0].As<Int32>()->Value(); in New()
262 /* This is called once per second by loop->timer. It is used to constantly */
263 /* call back into c-ares for possibly processing timeouts. */
265 ChannelWrap* channel = static_cast<ChannelWrap*>(handle->data); in AresTimeout()
266 CHECK_EQ(channel->timer_handle(), handle); in AresTimeout()
267 CHECK_EQ(false, channel->task_list()->empty()); in AresTimeout()
268 ares_process_fd(channel->cares_channel(), ARES_SOCKET_BAD, ARES_SOCKET_BAD); in AresTimeout()
274 ChannelWrap* channel = task->channel; in ares_poll_cb()
277 uv_timer_again(channel->timer_handle()); in ares_poll_cb()
282 ares_process_fd(channel->cares_channel(), task->sock, task->sock); in ares_poll_cb()
287 ares_process_fd(channel->cares_channel(), in ares_poll_cb()
288 events & UV_READABLE ? task->sock : ARES_SOCKET_BAD, in ares_poll_cb()
289 events & UV_WRITABLE ? task->sock : ARES_SOCKET_BAD); in ares_poll_cb()
299 tracker->TrackField("channel", channel); in MemoryInfo()
306 task->channel = channel; in ares_task_create()
307 task->sock = sock; in ares_task_create()
309 if (uv_poll_init_socket(channel->env()->event_loop(), in ares_task_create()
310 &task->poll_watcher, sock) < 0) { in ares_task_create()
330 auto it = channel->task_list()->find(&lookup_task); in ares_sockstate_cb()
332 task = (it == channel->task_list()->end()) ? nullptr : *it; in ares_sockstate_cb()
337 channel->StartTimer(); in ares_sockstate_cb()
347 channel->task_list()->insert(task); in ares_sockstate_cb()
352 uv_poll_start(&task->poll_watcher, in ares_sockstate_cb()
357 /* read == 0 and write == 0 this is c-ares's way of notifying us that */ in ares_sockstate_cb()
363 channel->task_list()->erase(it); in ares_sockstate_cb()
364 channel->env()->CloseHandle(&task->poll_watcher, ares_poll_close_cb); in ares_sockstate_cb()
366 if (channel->task_list()->empty()) { in ares_sockstate_cb()
367 channel->CloseTimer(); in ares_sockstate_cb()
376 EscapableHandleScope scope(env->isolate()); in HostentToNames()
377 auto context = env->context(); in HostentToNames()
379 Local<Array> names = append ? append_to : Array::New(env->isolate()); in HostentToNames()
380 size_t offset = names->Length(); in HostentToNames()
382 for (uint32_t i = 0; host->h_aliases[i] != nullptr; ++i) { in HostentToNames()
383 Local<String> address = OneByteString(env->isolate(), host->h_aliases[i]); in HostentToNames()
384 names->Set(context, i + offset, address).Check(); in HostentToNames()
393 if (host->h_addr_list != nullptr) { in safe_free_hostent()
395 while (host->h_addr_list[idx]) { in safe_free_hostent()
396 free(host->h_addr_list[idx++]); in safe_free_hostent()
398 free(host->h_addr_list); in safe_free_hostent()
399 host->h_addr_list = nullptr; in safe_free_hostent()
402 if (host->h_aliases != nullptr) { in safe_free_hostent()
404 while (host->h_aliases[idx]) { in safe_free_hostent()
405 free(host->h_aliases[idx++]); in safe_free_hostent()
407 free(host->h_aliases); in safe_free_hostent()
408 host->h_aliases = nullptr; in safe_free_hostent()
411 free(host->h_name); in safe_free_hostent()
416 dest->h_addr_list = nullptr; in cares_wrap_hostent_cpy()
417 dest->h_addrtype = 0; in cares_wrap_hostent_cpy()
418 dest->h_aliases = nullptr; in cares_wrap_hostent_cpy()
419 dest->h_length = 0; in cares_wrap_hostent_cpy()
420 dest->h_name = nullptr; in cares_wrap_hostent_cpy()
423 size_t name_size = strlen(src->h_name) + 1; in cares_wrap_hostent_cpy()
424 dest->h_name = node::Malloc<char>(name_size); in cares_wrap_hostent_cpy()
425 memcpy(dest->h_name, src->h_name, name_size); in cares_wrap_hostent_cpy()
430 src->h_aliases[alias_count] != nullptr; in cares_wrap_hostent_cpy()
434 dest->h_aliases = node::Malloc<char*>(alias_count + 1); in cares_wrap_hostent_cpy()
436 const size_t cur_alias_size = strlen(src->h_aliases[i]) + 1; in cares_wrap_hostent_cpy()
437 dest->h_aliases[i] = node::Malloc(cur_alias_size); in cares_wrap_hostent_cpy()
438 memcpy(dest->h_aliases[i], src->h_aliases[i], cur_alias_size); in cares_wrap_hostent_cpy()
440 dest->h_aliases[alias_count] = nullptr; in cares_wrap_hostent_cpy()
445 src->h_addr_list[list_count] != nullptr; in cares_wrap_hostent_cpy()
449 dest->h_addr_list = node::Malloc<char*>(list_count + 1); in cares_wrap_hostent_cpy()
451 dest->h_addr_list[i] = node::Malloc(src->h_length); in cares_wrap_hostent_cpy()
452 memcpy(dest->h_addr_list[i], src->h_addr_list[i], src->h_length); in cares_wrap_hostent_cpy()
454 dest->h_addr_list[list_count] = nullptr; in cares_wrap_hostent_cpy()
457 dest->h_length = src->h_length; in cares_wrap_hostent_cpy()
458 dest->h_addrtype = src->h_addrtype; in cares_wrap_hostent_cpy()
475 // so this is a no-op except for the first call to it. in Setup()
478 return env()->ThrowError(ToErrorCodeString(r)); in Setup()
489 return env()->ThrowError(ToErrorCodeString(r)); in Setup()
498 timer_handle_->data = static_cast<void*>(this); in StartTimer()
499 uv_timer_init(env()->event_loop(), timer_handle_); in StartTimer()
513 env()->CloseHandle(timer_handle_, [](uv_timer_t* handle) { delete handle; }); in CloseTimer()
553 /* if no server or multi-servers, ignore */ in EnsureServers()
555 if (servers->next != nullptr) { in EnsureServers()
585 : AsyncWrap(channel->env(), req_wrap_obj, AsyncWrap::PROVIDER_QUERYWRAP), in QueryWrap()
613 channel_->EnsureServers(); in AresQuery()
617 ares_query(channel_->cares_channel(), name, dnsclass, type, Callback, in AresQuery()
631 const int status = response_data_->status; in AfterResponse()
635 } else if (!response_data_->is_host) { in AfterResponse()
636 Parse(response_data_->buf.data, response_data_->buf.size); in AfterResponse()
638 Parse(response_data_->host.get()); in AfterResponse()
652 wrap->callback_ptr_ = nullptr; in FromCallbackPointer()
667 wrap->response_data_ = std::make_unique<ResponseData>(); in Callback()
668 ResponseData* data = wrap->response_data_.get(); in Callback()
669 data->status = status; in Callback()
670 data->is_host = false; in Callback()
671 data->buf = MallocedBuffer<unsigned char>(buf_copy, answer_len); in Callback()
673 wrap->QueueResponseCallback(status); in Callback()
687 wrap->response_data_ = std::make_unique<ResponseData>(); in Callback()
688 ResponseData* data = wrap->response_data_.get(); in Callback()
689 data->status = status; in Callback()
690 data->host.reset(host_copy); in Callback()
691 data->is_host = true; in Callback()
693 wrap->QueueResponseCallback(status); in Callback()
698 env()->SetImmediate([this, strong_ref](Environment*) { in QueueResponseCallback()
705 channel_->set_query_last_ok(status != ARES_ECONNREFUSED); in QueueResponseCallback()
706 channel_->ModifyActivityQueryCount(-1); in QueueResponseCallback()
711 HandleScope handle_scope(env()->isolate()); in CallOnComplete()
712 Context::Scope context_scope(env()->context()); in CallOnComplete()
714 Integer::New(env()->isolate(), 0), in CallOnComplete()
718 const int argc = arraysize(argv) - extra.IsEmpty(); in CallOnComplete()
722 MakeCallback(env()->oncomplete_string(), argc, argv); in CallOnComplete()
727 HandleScope handle_scope(env()->isolate()); in ParseError()
728 Context::Scope context_scope(env()->context()); in ParseError()
730 Local<Value> arg = OneByteString(env()->isolate(), code); in ParseError()
734 MakeCallback(env()->oncomplete_string(), 1, &arg); in ParseError()
761 auto isolate = env->isolate(); in AddrTTLToArray()
778 HandleScope handle_scope(env->isolate()); in ParseGeneralReply()
779 auto context = env->context(); in ParseGeneralReply()
817 if ((*type == ns_t_cname_or_a && host->h_name && host->h_aliases[0]) || in ParseGeneralReply()
822 ret->Set(context, in ParseGeneralReply()
823 ret->Length(), in ParseGeneralReply()
824 OneByteString(env->isolate(), host->h_name)).Check(); in ParseGeneralReply()
835 uint32_t offset = ret->Length(); in ParseGeneralReply()
836 for (uint32_t i = 0; host->h_aliases[i] != nullptr; i++) { in ParseGeneralReply()
837 auto alias = OneByteString(env->isolate(), host->h_aliases[i]); in ParseGeneralReply()
838 ret->Set(context, i + offset, alias).Check(); in ParseGeneralReply()
841 uint32_t offset = ret->Length(); in ParseGeneralReply()
843 for (uint32_t i = 0; host->h_addr_list[i] != nullptr; ++i) { in ParseGeneralReply()
844 uv_inet_ntop(host->h_addrtype, host->h_addr_list[i], ip, sizeof(ip)); in ParseGeneralReply()
845 auto address = OneByteString(env->isolate(), ip); in ParseGeneralReply()
846 ret->Set(context, i + offset, address).Check(); in ParseGeneralReply()
861 HandleScope handle_scope(env->isolate()); in ParseMxReply()
862 auto context = env->context(); in ParseMxReply()
870 uint32_t offset = ret->Length(); in ParseMxReply()
872 for (uint32_t i = 0; current != nullptr; ++i, current = current->next) { in ParseMxReply()
873 Local<Object> mx_record = Object::New(env->isolate()); in ParseMxReply()
874 mx_record->Set(context, in ParseMxReply()
875 env->exchange_string(), in ParseMxReply()
876 OneByteString(env->isolate(), current->host)).Check(); in ParseMxReply()
877 mx_record->Set(context, in ParseMxReply()
878 env->priority_string(), in ParseMxReply()
879 Integer::New(env->isolate(), current->priority)).Check(); in ParseMxReply()
881 mx_record->Set(context, in ParseMxReply()
882 env->type_string(), in ParseMxReply()
883 env->dns_mx_string()).Check(); in ParseMxReply()
885 ret->Set(context, i + offset, mx_record).Check(); in ParseMxReply()
897 HandleScope handle_scope(env->isolate()); in ParseTxtReply()
898 auto context = env->context(); in ParseTxtReply()
911 uint32_t offset = ret->Length(); in ParseTxtReply()
912 for (j = 0; current != nullptr; current = current->next) { in ParseTxtReply()
914 OneByteString(env->isolate(), current->txt, current->length); in ParseTxtReply()
916 // New record found - write out the current chunk in ParseTxtReply()
917 if (current->record_start) { in ParseTxtReply()
920 Local<Object> elem = Object::New(env->isolate()); in ParseTxtReply()
921 elem->Set(context, env->entries_string(), txt_chunk).Check(); in ParseTxtReply()
922 elem->Set(context, in ParseTxtReply()
923 env->type_string(), in ParseTxtReply()
924 env->dns_txt_string()).Check(); in ParseTxtReply()
925 ret->Set(context, offset + i++, elem).Check(); in ParseTxtReply()
927 ret->Set(context, offset + i++, txt_chunk).Check(); in ParseTxtReply()
931 txt_chunk = Array::New(env->isolate()); in ParseTxtReply()
935 txt_chunk->Set(context, j++, txt).Check(); in ParseTxtReply()
941 Local<Object> elem = Object::New(env->isolate()); in ParseTxtReply()
942 elem->Set(context, env->entries_string(), txt_chunk).Check(); in ParseTxtReply()
943 elem->Set(context, in ParseTxtReply()
944 env->type_string(), in ParseTxtReply()
945 env->dns_txt_string()).Check(); in ParseTxtReply()
946 ret->Set(context, offset + i, elem).Check(); in ParseTxtReply()
948 ret->Set(context, offset + i, txt_chunk).Check(); in ParseTxtReply()
962 HandleScope handle_scope(env->isolate()); in ParseSrvReply()
963 auto context = env->context(); in ParseSrvReply()
972 int offset = ret->Length(); in ParseSrvReply()
973 for (uint32_t i = 0; current != nullptr; ++i, current = current->next) { in ParseSrvReply()
974 Local<Object> srv_record = Object::New(env->isolate()); in ParseSrvReply()
975 srv_record->Set(context, in ParseSrvReply()
976 env->name_string(), in ParseSrvReply()
977 OneByteString(env->isolate(), current->host)).Check(); in ParseSrvReply()
978 srv_record->Set(context, in ParseSrvReply()
979 env->port_string(), in ParseSrvReply()
980 Integer::New(env->isolate(), current->port)).Check(); in ParseSrvReply()
981 srv_record->Set(context, in ParseSrvReply()
982 env->priority_string(), in ParseSrvReply()
983 Integer::New(env->isolate(), current->priority)).Check(); in ParseSrvReply()
984 srv_record->Set(context, in ParseSrvReply()
985 env->weight_string(), in ParseSrvReply()
986 Integer::New(env->isolate(), current->weight)).Check(); in ParseSrvReply()
988 srv_record->Set(context, in ParseSrvReply()
989 env->type_string(), in ParseSrvReply()
990 env->dns_srv_string()).Check(); in ParseSrvReply()
992 ret->Set(context, i + offset, srv_record).Check(); in ParseSrvReply()
1005 HandleScope handle_scope(env->isolate()); in ParseNaptrReply()
1006 auto context = env->context(); in ParseNaptrReply()
1016 int offset = ret->Length(); in ParseNaptrReply()
1017 for (uint32_t i = 0; current != nullptr; ++i, current = current->next) { in ParseNaptrReply()
1018 Local<Object> naptr_record = Object::New(env->isolate()); in ParseNaptrReply()
1019 naptr_record->Set(context, in ParseNaptrReply()
1020 env->flags_string(), in ParseNaptrReply()
1021 OneByteString(env->isolate(), current->flags)).Check(); in ParseNaptrReply()
1022 naptr_record->Set(context, in ParseNaptrReply()
1023 env->service_string(), in ParseNaptrReply()
1024 OneByteString(env->isolate(), in ParseNaptrReply()
1025 current->service)).Check(); in ParseNaptrReply()
1026 naptr_record->Set(context, in ParseNaptrReply()
1027 env->regexp_string(), in ParseNaptrReply()
1028 OneByteString(env->isolate(), in ParseNaptrReply()
1029 current->regexp)).Check(); in ParseNaptrReply()
1030 naptr_record->Set(context, in ParseNaptrReply()
1031 env->replacement_string(), in ParseNaptrReply()
1032 OneByteString(env->isolate(), in ParseNaptrReply()
1033 current->replacement)).Check(); in ParseNaptrReply()
1034 naptr_record->Set(context, in ParseNaptrReply()
1035 env->order_string(), in ParseNaptrReply()
1036 Integer::New(env->isolate(), current->order)).Check(); in ParseNaptrReply()
1037 naptr_record->Set(context, in ParseNaptrReply()
1038 env->preference_string(), in ParseNaptrReply()
1039 Integer::New(env->isolate(), in ParseNaptrReply()
1040 current->preference)).Check(); in ParseNaptrReply()
1042 naptr_record->Set(context, in ParseNaptrReply()
1043 env->type_string(), in ParseNaptrReply()
1044 env->dns_naptr_string()).Check(); in ParseNaptrReply()
1046 ret->Set(context, i + offset, naptr_record).Check(); in ParseNaptrReply()
1058 EscapableHandleScope handle_scope(env->isolate()); in ParseSoaReply()
1059 auto context = env->context(); in ParseSoaReply()
1139 Local<Object> soa_record = Object::New(env->isolate()); in ParseSoaReply()
1140 soa_record->Set(context, in ParseSoaReply()
1141 env->nsname_string(), in ParseSoaReply()
1142 OneByteString(env->isolate(), nsname.get())).Check(); in ParseSoaReply()
1143 soa_record->Set(context, in ParseSoaReply()
1144 env->hostmaster_string(), in ParseSoaReply()
1145 OneByteString(env->isolate(), in ParseSoaReply()
1147 soa_record->Set(context, in ParseSoaReply()
1148 env->serial_string(), in ParseSoaReply()
1149 Integer::NewFromUnsigned(env->isolate(), serial)).Check(); in ParseSoaReply()
1150 soa_record->Set(context, in ParseSoaReply()
1151 env->refresh_string(), in ParseSoaReply()
1152 Integer::New(env->isolate(), refresh)).Check(); in ParseSoaReply()
1153 soa_record->Set(context, in ParseSoaReply()
1154 env->retry_string(), in ParseSoaReply()
1155 Integer::New(env->isolate(), retry)).Check(); in ParseSoaReply()
1156 soa_record->Set(context, in ParseSoaReply()
1157 env->expire_string(), in ParseSoaReply()
1158 Integer::New(env->isolate(), expire)).Check(); in ParseSoaReply()
1159 soa_record->Set(context, in ParseSoaReply()
1160 env->minttl_string(), in ParseSoaReply()
1161 Integer::NewFromUnsigned(env->isolate(), minttl)).Check(); in ParseSoaReply()
1162 soa_record->Set(context, in ParseSoaReply()
1163 env->type_string(), in ParseSoaReply()
1164 env->dns_soa_string()).Check(); in ParseSoaReply()
1195 HandleScope handle_scope(env()->isolate()); in Parse()
1196 auto context = env()->context(); in Parse()
1199 Local<Array> ret = Array::New(env()->isolate()); in Parse()
1214 uint32_t a_count = ret->Length(); in Parse()
1223 Local<Object> obj = Object::New(env()->isolate()); in Parse()
1224 obj->Set(context, in Parse()
1225 env()->address_string(), in Parse()
1226 ret->Get(context, i).ToLocalChecked()).Check(); in Parse()
1227 obj->Set(context, in Parse()
1228 env()->ttl_string(), in Parse()
1230 env()->isolate(), addrttls[i].ttl)).Check(); in Parse()
1231 obj->Set(context, in Parse()
1232 env()->type_string(), in Parse()
1233 env()->dns_a_string()).Check(); in Parse()
1234 ret->Set(context, i, obj).Check(); in Parse()
1238 Local<Object> obj = Object::New(env()->isolate()); in Parse()
1239 obj->Set(context, in Parse()
1240 env()->value_string(), in Parse()
1241 ret->Get(context, i).ToLocalChecked()).Check(); in Parse()
1242 obj->Set(context, in Parse()
1243 env()->type_string(), in Parse()
1244 env()->dns_cname_string()).Check(); in Parse()
1245 ret->Set(context, i, obj).Check(); in Parse()
1261 uint32_t aaaa_count = ret->Length() - a_count; in Parse()
1268 CHECK_EQ(ret->Length(), a_count + aaaa_count); in Parse()
1269 for (uint32_t i = a_count; i < ret->Length(); i++) { in Parse()
1270 Local<Object> obj = Object::New(env()->isolate()); in Parse()
1271 obj->Set(context, in Parse()
1272 env()->address_string(), in Parse()
1273 ret->Get(context, i).ToLocalChecked()).Check(); in Parse()
1274 obj->Set(context, in Parse()
1275 env()->ttl_string(), in Parse()
1277 env()->isolate(), addr6ttls[i - a_count].ttl)).Check(); in Parse()
1278 obj->Set(context, in Parse()
1279 env()->type_string(), in Parse()
1280 env()->dns_aaaa_string()).Check(); in Parse()
1281 ret->Set(context, i, obj).Check(); in Parse()
1293 old_count = ret->Length(); in Parse()
1299 for (uint32_t i = old_count; i < ret->Length(); i++) { in Parse()
1300 Local<Object> obj = Object::New(env()->isolate()); in Parse()
1301 obj->Set(context, in Parse()
1302 env()->value_string(), in Parse()
1303 ret->Get(context, i).ToLocalChecked()).Check(); in Parse()
1304 obj->Set(context, in Parse()
1305 env()->type_string(), in Parse()
1306 env()->dns_ns_string()).Check(); in Parse()
1307 ret->Set(context, i, obj).Check(); in Parse()
1317 /* Parse SRV records */ in Parse()
1325 old_count = ret->Length(); in Parse()
1327 for (uint32_t i = old_count; i < ret->Length(); i++) { in Parse()
1328 Local<Object> obj = Object::New(env()->isolate()); in Parse()
1329 obj->Set(context, in Parse()
1330 env()->value_string(), in Parse()
1331 ret->Get(context, i).ToLocalChecked()).Check(); in Parse()
1332 obj->Set(context, in Parse()
1333 env()->type_string(), in Parse()
1334 env()->dns_ptr_string()).Check(); in Parse()
1335 ret->Set(context, i, obj).Check(); in Parse()
1353 ret->Set(context, ret->Length(), soa_record).Check(); in Parse()
1377 HandleScope handle_scope(env()->isolate()); in Parse()
1378 Context::Scope context_scope(env()->context()); in Parse()
1382 Local<Array> ret = Array::New(env()->isolate()); in Parse()
1423 HandleScope handle_scope(env()->isolate()); in Parse()
1424 Context::Scope context_scope(env()->context()); in Parse()
1428 Local<Array> ret = Array::New(env()->isolate()); in Parse()
1469 HandleScope handle_scope(env()->isolate()); in Parse()
1470 Context::Scope context_scope(env()->context()); in Parse()
1472 Local<Array> ret = Array::New(env()->isolate()); in Parse()
1480 this->CallOnComplete(ret); in Parse()
1502 HandleScope handle_scope(env()->isolate()); in Parse()
1503 Context::Scope context_scope(env()->context()); in Parse()
1505 Local<Array> mx_records = Array::New(env()->isolate()); in Parse()
1513 this->CallOnComplete(mx_records); in Parse()
1535 HandleScope handle_scope(env()->isolate()); in Parse()
1536 Context::Scope context_scope(env()->context()); in Parse()
1539 Local<Array> names = Array::New(env()->isolate()); in Parse()
1546 this->CallOnComplete(names); in Parse()
1568 HandleScope handle_scope(env()->isolate()); in Parse()
1569 Context::Scope context_scope(env()->context()); in Parse()
1571 Local<Array> txt_records = Array::New(env()->isolate()); in Parse()
1578 this->CallOnComplete(txt_records); in Parse()
1600 HandleScope handle_scope(env()->isolate()); in Parse()
1601 Context::Scope context_scope(env()->context()); in Parse()
1603 Local<Array> srv_records = Array::New(env()->isolate()); in Parse()
1610 this->CallOnComplete(srv_records); in Parse()
1631 HandleScope handle_scope(env()->isolate()); in Parse()
1632 Context::Scope context_scope(env()->context()); in Parse()
1635 Local<Array> aliases = Array::New(env()->isolate()); in Parse()
1643 this->CallOnComplete(aliases); in Parse()
1664 HandleScope handle_scope(env()->isolate()); in Parse()
1665 Context::Scope context_scope(env()->context()); in Parse()
1667 Local<Array> naptr_records = Array::New(env()->isolate()); in Parse()
1674 this->CallOnComplete(naptr_records); in Parse()
1696 HandleScope handle_scope(env()->isolate()); in Parse()
1697 auto context = env()->context(); in Parse()
1708 Local<Object> soa_record = Object::New(env()->isolate()); in Parse()
1710 soa_record->Set(context, in Parse()
1711 env()->nsname_string(), in Parse()
1712 OneByteString(env()->isolate(), in Parse()
1713 soa_out->nsname)).Check(); in Parse()
1714 soa_record->Set(context, in Parse()
1715 env()->hostmaster_string(), in Parse()
1716 OneByteString(env()->isolate(), in Parse()
1717 soa_out->hostmaster)).Check(); in Parse()
1718 soa_record->Set(context, in Parse()
1719 env()->serial_string(), in Parse()
1721 env()->isolate(), soa_out->serial)).Check(); in Parse()
1722 soa_record->Set(context, in Parse()
1723 env()->refresh_string(), in Parse()
1724 Integer::New(env()->isolate(), in Parse()
1725 soa_out->refresh)).Check(); in Parse()
1726 soa_record->Set(context, in Parse()
1727 env()->retry_string(), in Parse()
1728 Integer::New(env()->isolate(), soa_out->retry)).Check(); in Parse()
1729 soa_record->Set(context, in Parse()
1730 env()->expire_string(), in Parse()
1731 Integer::New(env()->isolate(), soa_out->expire)).Check(); in Parse()
1732 soa_record->Set(context, in Parse()
1733 env()->minttl_string(), in Parse()
1735 env()->isolate(), soa_out->minttl)).Check(); in Parse()
1739 this->CallOnComplete(soa_record); in Parse()
1767 "family", family == AF_INET ? "ipv4" : "ipv6"); in Send()
1769 ares_gethostbyaddr(channel_->cares_channel(), in Send()
1784 HandleScope handle_scope(env()->isolate()); in Parse()
1785 Context::Scope context_scope(env()->context()); in Parse()
1786 this->CallOnComplete(HostentToNames(env(), host)); in Parse()
1798 CHECK(args[0]->IsObject()); in Query()
1799 CHECK(args[1]->IsString()); in Query()
1805 node::Utf8Value name(env->isolate(), string); in Query()
1806 channel->ModifyActivityQueryCount(1); in Query()
1807 int err = wrap->Send(*name); in Query()
1809 channel->ModifyActivityQueryCount(-1); in Query()
1821 static_cast<GetAddrInfoReqWrap*>(req->data)}; in AfterGetAddrInfo()
1822 Environment* env = req_wrap->env(); in AfterGetAddrInfo()
1824 HandleScope handle_scope(env->isolate()); in AfterGetAddrInfo()
1825 Context::Scope context_scope(env->context()); in AfterGetAddrInfo()
1828 Integer::New(env->isolate(), status), in AfterGetAddrInfo()
1829 Null(env->isolate()) in AfterGetAddrInfo()
1833 const bool verbatim = req_wrap->verbatim(); in AfterGetAddrInfo()
1836 Local<Array> results = Array::New(env->isolate()); in AfterGetAddrInfo()
1839 for (auto p = res; p != nullptr; p = p->ai_next) { in AfterGetAddrInfo()
1840 CHECK_EQ(p->ai_socktype, SOCK_STREAM); in AfterGetAddrInfo()
1843 if (want_ipv4 && p->ai_family == AF_INET) { in AfterGetAddrInfo()
1845 &(reinterpret_cast<struct sockaddr_in*>(p->ai_addr)->sin_addr)); in AfterGetAddrInfo()
1846 } else if (want_ipv6 && p->ai_family == AF_INET6) { in AfterGetAddrInfo()
1848 &(reinterpret_cast<struct sockaddr_in6*>(p->ai_addr)->sin6_addr)); in AfterGetAddrInfo()
1854 if (uv_inet_ntop(p->ai_family, addr, ip, sizeof(ip))) in AfterGetAddrInfo()
1857 Local<String> s = OneByteString(env->isolate(), ip); in AfterGetAddrInfo()
1858 results->Set(env->context(), n, s).Check(); in AfterGetAddrInfo()
1869 argv[0] = Integer::New(env->isolate(), UV_EAI_NODATA); in AfterGetAddrInfo()
1882 req_wrap->MakeCallback(env->oncomplete_string(), arraysize(argv), argv); in AfterGetAddrInfo()
1891 static_cast<GetNameInfoReqWrap*>(req->data)}; in AfterGetNameInfo()
1892 Environment* env = req_wrap->env(); in AfterGetNameInfo()
1894 HandleScope handle_scope(env->isolate()); in AfterGetNameInfo()
1895 Context::Scope context_scope(env->context()); in AfterGetNameInfo()
1898 Integer::New(env->isolate(), status), in AfterGetNameInfo()
1899 Null(env->isolate()), in AfterGetNameInfo()
1900 Null(env->isolate()) in AfterGetNameInfo()
1905 Local<String> js_hostname = OneByteString(env->isolate(), hostname); in AfterGetNameInfo()
1906 Local<String> js_service = OneByteString(env->isolate(), service); in AfterGetNameInfo()
1917 req_wrap->MakeCallback(env->oncomplete_string(), arraysize(argv), argv); in AfterGetNameInfo()
1921 decltype(static_cast<ares_addr_port_node*>(nullptr)->addr);
1950 CHECK(args[0]->IsObject()); in GetAddrInfo()
1951 CHECK(args[1]->IsString()); in GetAddrInfo()
1952 CHECK(args[2]->IsInt32()); in GetAddrInfo()
1953 CHECK(args[4]->IsBoolean()); in GetAddrInfo()
1955 node::Utf8Value hostname(env->isolate(), args[1]); in GetAddrInfo()
1958 if (args[3]->IsInt32()) { in GetAddrInfo()
1959 flags = args[3].As<Int32>()->Value(); in GetAddrInfo()
1964 switch (args[2].As<Int32>()->Value()) { in GetAddrInfo()
1980 args[4]->IsTrue()); in GetAddrInfo()
1992 family == AF_INET ? "ipv4" : family == AF_INET6 ? "ipv6" : "unspec"); in GetAddrInfo()
1994 int err = req_wrap->Dispatch(uv_getaddrinfo, in GetAddrInfo()
2010 CHECK(args[0]->IsObject()); in GetNameInfo()
2011 CHECK(args[1]->IsString()); in GetNameInfo()
2012 CHECK(args[2]->IsUint32()); in GetNameInfo()
2014 node::Utf8Value ip(env->isolate(), args[1]); in GetNameInfo()
2015 const unsigned port = args[2]->Uint32Value(env->context()).FromJust(); in GetNameInfo()
2027 int err = req_wrap->Dispatch(uv_getnameinfo, in GetNameInfo()
2044 Local<Array> server_array = Array::New(env->isolate()); in GetServers()
2048 int r = ares_get_servers_ports(channel->cares_channel(), &servers); in GetServers()
2054 for (uint32_t i = 0; cur != nullptr; ++i, cur = cur->next) { in GetServers()
2057 const void* caddr = static_cast<const void*>(&cur->addr); in GetServers()
2058 int err = uv_inet_ntop(cur->family, caddr, ip, sizeof(ip)); in GetServers()
2062 OneByteString(env->isolate(), ip), in GetServers()
2063 Integer::New(env->isolate(), cur->udp_port) in GetServers()
2066 if (server_array->Set(env->context(), i, in GetServers()
2067 Array::New(env->isolate(), ret, arraysize(ret))) in GetServers()
2082 if (channel->active_query_count()) { in SetServers()
2086 CHECK(args[0]->IsArray()); in SetServers()
2090 uint32_t len = arr->Length(); in SetServers()
2093 int rv = ares_set_servers(channel->cares_channel(), nullptr); in SetServers()
2103 CHECK(arr->Get(env->context(), i).ToLocalChecked()->IsArray()); in SetServers()
2106 Local<Array>::Cast(arr->Get(env->context(), i).ToLocalChecked()); in SetServers()
2108 CHECK(elm->Get(env->context(), in SetServers()
2109 0).ToLocalChecked()->Int32Value(env->context()).FromJust()); in SetServers()
2110 CHECK(elm->Get(env->context(), 1).ToLocalChecked()->IsString()); in SetServers()
2111 CHECK(elm->Get(env->context(), in SetServers()
2112 2).ToLocalChecked()->Int32Value(env->context()).FromJust()); in SetServers()
2114 int fam = elm->Get(env->context(), 0) in SetServers()
2115 .ToLocalChecked()->Int32Value(env->context()).FromJust(); in SetServers()
2116 node::Utf8Value ip(env->isolate(), in SetServers()
2117 elm->Get(env->context(), 1).ToLocalChecked()); in SetServers()
2118 int port = elm->Get(env->context(), 2) in SetServers()
2119 .ToLocalChecked()->Int32Value(env->context()).FromJust(); in SetServers()
2123 cur->tcp_port = cur->udp_port = port; in SetServers()
2126 cur->family = AF_INET; in SetServers()
2127 err = uv_inet_pton(AF_INET, *ip, &cur->addr); in SetServers()
2130 cur->family = AF_INET6; in SetServers()
2131 err = uv_inet_pton(AF_INET6, *ip, &cur->addr); in SetServers()
2140 cur->next = nullptr; in SetServers()
2143 last->next = cur; in SetServers()
2149 err = ares_set_servers_ports(channel->cares_channel(), &servers[0]); in SetServers()
2154 channel->set_is_servers_default(false); in SetServers()
2166 ares_cancel(channel->cares_channel()); in Cancel()
2172 int code = args[0]->Int32Value(env->context()).FromJust(); in StrError()
2176 args.GetReturnValue().Set(OneByteString(env->isolate(), errmsg)); in StrError()
2180 void Initialize(Local<Object> target, in Initialize() argument
2186 env->SetMethod(target, "getaddrinfo", GetAddrInfo); in Initialize()
2187 env->SetMethod(target, "getnameinfo", GetNameInfo); in Initialize()
2188 env->SetMethodNoSideEffect(target, "canonicalizeIP", CanonicalizeIP); in Initialize()
2190 env->SetMethod(target, "strerror", StrError); in Initialize()
2192 target->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(), "AF_INET"), in Initialize()
2193 Integer::New(env->isolate(), AF_INET)).Check(); in Initialize()
2194 target->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(), "AF_INET6"), in Initialize()
2195 Integer::New(env->isolate(), AF_INET6)).Check(); in Initialize()
2196 target->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(), in Initialize()
2198 Integer::New(env->isolate(), AF_UNSPEC)).Check(); in Initialize()
2199 target->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(), in Initialize()
2201 Integer::New(env->isolate(), AI_ADDRCONFIG)).Check(); in Initialize()
2202 target->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(), in Initialize()
2204 Integer::New(env->isolate(), AI_ALL)).Check(); in Initialize()
2205 target->Set(env->context(), FIXED_ONE_BYTE_STRING(env->isolate(), in Initialize()
2207 Integer::New(env->isolate(), AI_V4MAPPED)).Check(); in Initialize()
2211 aiw->Inherit(AsyncWrap::GetConstructorTemplate(env)); in Initialize()
2213 FIXED_ONE_BYTE_STRING(env->isolate(), "GetAddrInfoReqWrap"); in Initialize()
2214 aiw->SetClassName(addrInfoWrapString); in Initialize()
2215 target->Set(env->context(), in Initialize()
2217 aiw->GetFunction(context).ToLocalChecked()).Check(); in Initialize()
2221 niw->Inherit(AsyncWrap::GetConstructorTemplate(env)); in Initialize()
2223 FIXED_ONE_BYTE_STRING(env->isolate(), "GetNameInfoReqWrap"); in Initialize()
2224 niw->SetClassName(nameInfoWrapString); in Initialize()
2225 target->Set(env->context(), in Initialize()
2227 niw->GetFunction(context).ToLocalChecked()).Check(); in Initialize()
2231 qrw->Inherit(AsyncWrap::GetConstructorTemplate(env)); in Initialize()
2233 FIXED_ONE_BYTE_STRING(env->isolate(), "QueryReqWrap"); in Initialize()
2234 qrw->SetClassName(queryWrapString); in Initialize()
2235 target->Set(env->context(), in Initialize()
2237 qrw->GetFunction(context).ToLocalChecked()).Check(); in Initialize()
2240 env->NewFunctionTemplate(ChannelWrap::New); in Initialize()
2241 channel_wrap->InstanceTemplate()->SetInternalFieldCount( in Initialize()
2243 channel_wrap->Inherit(AsyncWrap::GetConstructorTemplate(env)); in Initialize()
2245 env->SetProtoMethod(channel_wrap, "queryAny", Query<QueryAnyWrap>); in Initialize()
2246 env->SetProtoMethod(channel_wrap, "queryA", Query<QueryAWrap>); in Initialize()
2247 env->SetProtoMethod(channel_wrap, "queryAaaa", Query<QueryAaaaWrap>); in Initialize()
2248 env->SetProtoMethod(channel_wrap, "queryCname", Query<QueryCnameWrap>); in Initialize()
2249 env->SetProtoMethod(channel_wrap, "queryMx", Query<QueryMxWrap>); in Initialize()
2250 env->SetProtoMethod(channel_wrap, "queryNs", Query<QueryNsWrap>); in Initialize()
2251 env->SetProtoMethod(channel_wrap, "queryTxt", Query<QueryTxtWrap>); in Initialize()
2252 env->SetProtoMethod(channel_wrap, "querySrv", Query<QuerySrvWrap>); in Initialize()
2253 env->SetProtoMethod(channel_wrap, "queryPtr", Query<QueryPtrWrap>); in Initialize()
2254 env->SetProtoMethod(channel_wrap, "queryNaptr", Query<QueryNaptrWrap>); in Initialize()
2255 env->SetProtoMethod(channel_wrap, "querySoa", Query<QuerySoaWrap>); in Initialize()
2256 env->SetProtoMethod(channel_wrap, "getHostByAddr", Query<GetHostByAddrWrap>); in Initialize()
2258 env->SetProtoMethodNoSideEffect(channel_wrap, "getServers", GetServers); in Initialize()
2259 env->SetProtoMethod(channel_wrap, "setServers", SetServers); in Initialize()
2260 env->SetProtoMethod(channel_wrap, "cancel", Cancel); in Initialize()
2263 FIXED_ONE_BYTE_STRING(env->isolate(), "ChannelWrap"); in Initialize()
2264 channel_wrap->SetClassName(channelWrapString); in Initialize()
2265 target->Set(env->context(), channelWrapString, in Initialize()
2266 channel_wrap->GetFunction(context).ToLocalChecked()).Check(); in Initialize()