Coverage Report

Created: 2025-12-10 07:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/node/src/cares_wrap.h
Line
Count
Source
1
#ifndef SRC_CARES_WRAP_H_
2
#define SRC_CARES_WRAP_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#define CARES_STATICLIB
7
8
#include "async_wrap.h"
9
#include "base_object.h"
10
#include "env.h"
11
#include "memory_tracker.h"
12
#include "node.h"
13
#include "node_internals.h"
14
#include "permission/permission.h"
15
#include "util.h"
16
17
#include "ares.h"
18
#include "v8.h"
19
#include "uv.h"
20
21
#include <unordered_set>
22
23
#ifdef __POSIX__
24
# include <netdb.h>
25
#endif  // __POSIX__
26
27
# include <ares_nameser.h>
28
29
namespace node {
30
namespace cares_wrap {
31
32
constexpr int ns_t_cname_or_a = -1;
33
constexpr int DNS_ESETSRVPENDING = -1000;
34
constexpr uint8_t DNS_ORDER_VERBATIM = 0;
35
constexpr uint8_t DNS_ORDER_IPV4_FIRST = 1;
36
constexpr uint8_t DNS_ORDER_IPV6_FIRST = 2;
37
38
class ChannelWrap;
39
40
inline void safe_free_hostent(struct hostent* host);
41
42
using HostEntPointer = DeleteFnPtr<hostent, ares_free_hostent>;
43
using SafeHostEntPointer = DeleteFnPtr<hostent, safe_free_hostent>;
44
45
0
inline const char* ToErrorCodeString(int status) {
46
0
  switch (status) {
47
0
#define V(code) case ARES_##code: return #code;
48
0
    V(EADDRGETNETWORKPARAMS)
49
0
    V(EBADFAMILY)
50
0
    V(EBADFLAGS)
51
0
    V(EBADHINTS)
52
0
    V(EBADNAME)
53
0
    V(EBADQUERY)
54
0
    V(EBADRESP)
55
0
    V(EBADSTR)
56
0
    V(ECANCELLED)
57
0
    V(ECONNREFUSED)
58
0
    V(EDESTRUCTION)
59
0
    V(EFILE)
60
0
    V(EFORMERR)
61
0
    V(ELOADIPHLPAPI)
62
0
    V(ENODATA)
63
0
    V(ENOMEM)
64
0
    V(ENONAME)
65
0
    V(ENOTFOUND)
66
0
    V(ENOTIMP)
67
0
    V(ENOTINITIALIZED)
68
0
    V(EOF)
69
0
    V(EREFUSED)
70
0
    V(ESERVFAIL)
71
0
    V(ETIMEOUT)
72
0
#undef V
73
0
  }
74
75
0
  return "UNKNOWN_ARES_ERROR";
76
0
}
77
78
inline void cares_wrap_hostent_cpy(
79
    struct hostent* dest,
80
0
    const struct hostent* src) {
81
0
  dest->h_addr_list = nullptr;
82
0
  dest->h_addrtype = 0;
83
0
  dest->h_aliases = nullptr;
84
0
  dest->h_length = 0;
85
0
  dest->h_name = nullptr;
86
87
  /* copy `h_name` */
88
0
  size_t name_size = strlen(src->h_name) + 1;
89
0
  dest->h_name = node::Malloc<char>(name_size);
90
0
  memcpy(dest->h_name, src->h_name, name_size);
91
92
  /* copy `h_aliases` */
93
0
  size_t alias_count;
94
0
  for (alias_count = 0;
95
0
      src->h_aliases[alias_count] != nullptr;
96
0
      alias_count++) {
97
0
  }
98
99
0
  dest->h_aliases = node::Malloc<char*>(alias_count + 1);
100
0
  for (size_t i = 0; i < alias_count; i++) {
101
0
    const size_t cur_alias_size = strlen(src->h_aliases[i]) + 1;
102
0
    dest->h_aliases[i] = node::Malloc(cur_alias_size);
103
0
    memcpy(dest->h_aliases[i], src->h_aliases[i], cur_alias_size);
104
0
  }
105
0
  dest->h_aliases[alias_count] = nullptr;
106
107
  /* copy `h_addr_list` */
108
0
  size_t list_count;
109
0
  for (list_count = 0;
110
0
      src->h_addr_list[list_count] != nullptr;
111
0
      list_count++) {
112
0
  }
113
114
0
  dest->h_addr_list = node::Malloc<char*>(list_count + 1);
115
0
  for (size_t i = 0; i < list_count; i++) {
116
0
    dest->h_addr_list[i] = node::Malloc(src->h_length);
117
0
    memcpy(dest->h_addr_list[i], src->h_addr_list[i], src->h_length);
118
0
  }
119
0
  dest->h_addr_list[list_count] = nullptr;
120
121
  /* work after work */
122
0
  dest->h_length = src->h_length;
123
0
  dest->h_addrtype = src->h_addrtype;
124
0
}
125
126
127
struct NodeAresTask final : public MemoryRetainer {
128
  ChannelWrap* channel;
129
  ares_socket_t sock;
130
  uv_poll_t poll_watcher;
131
132
  inline void MemoryInfo(MemoryTracker* trakcer) const override;
133
  SET_MEMORY_INFO_NAME(NodeAresTask)
134
  SET_SELF_SIZE(NodeAresTask)
135
136
  struct Hash {
137
0
    inline size_t operator()(NodeAresTask* a) const {
138
0
      return std::hash<ares_socket_t>()(a->sock);
139
0
    }
140
  };
141
142
  struct Equal {
143
0
    inline bool operator()(NodeAresTask* a, NodeAresTask* b) const {
144
0
      return a->sock == b->sock;
145
0
    }
146
  };
147
148
  static NodeAresTask* Create(ChannelWrap* channel, ares_socket_t sock);
149
150
  using List = std::unordered_set<NodeAresTask*, Hash, Equal>;
151
};
152
153
class ChannelWrap final : public AsyncWrap {
154
 public:
155
  ChannelWrap(Environment* env,
156
              v8::Local<v8::Object> object,
157
              int timeout,
158
              int tries,
159
              int max_timeout);
160
  ~ChannelWrap() override;
161
162
  static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
163
164
  void Setup();
165
  void EnsureServers();
166
  void StartTimer();
167
  void CloseTimer();
168
169
  void ModifyActivityQueryCount(int count);
170
171
0
  inline uv_timer_t* timer_handle() { return timer_handle_; }
172
0
  inline ares_channel cares_channel() { return channel_; }
173
0
  inline void set_query_last_ok(bool ok) { query_last_ok_ = ok; }
174
0
  inline void set_is_servers_default(bool is_default) {
175
0
    is_servers_default_ = is_default;
176
0
  }
177
0
  inline int active_query_count() { return active_query_count_; }
178
0
  inline NodeAresTask::List* task_list() { return &task_list_; }
179
180
  void MemoryInfo(MemoryTracker* tracker) const override;
181
  SET_MEMORY_INFO_NAME(ChannelWrap)
182
  SET_SELF_SIZE(ChannelWrap)
183
184
  static void AresTimeout(uv_timer_t* handle);
185
186
 private:
187
  uv_timer_t* timer_handle_ = nullptr;
188
  ares_channel channel_ = nullptr;
189
  bool query_last_ok_ = true;
190
  bool is_servers_default_ = true;
191
  bool library_inited_ = false;
192
  int timeout_;
193
  int tries_;
194
  int max_timeout_;
195
  int active_query_count_ = 0;
196
  NodeAresTask::List task_list_;
197
};
198
199
class GetAddrInfoReqWrap final : public ReqWrap<uv_getaddrinfo_t> {
200
 public:
201
  GetAddrInfoReqWrap(Environment* env,
202
                     v8::Local<v8::Object> req_wrap_obj,
203
                     uint8_t order);
204
205
  SET_NO_MEMORY_INFO()
206
  SET_MEMORY_INFO_NAME(GetAddrInfoReqWrap)
207
  SET_SELF_SIZE(GetAddrInfoReqWrap)
208
209
0
  uint8_t order() const { return order_; }
210
211
 private:
212
  const uint8_t order_;
213
};
214
215
class GetNameInfoReqWrap final : public ReqWrap<uv_getnameinfo_t> {
216
 public:
217
  GetNameInfoReqWrap(Environment* env, v8::Local<v8::Object> req_wrap_obj);
218
219
  SET_INSUFFICIENT_PERMISSION_ERROR_CALLBACK(permission::PermissionScope::kNet)
220
221
  SET_NO_MEMORY_INFO()
222
  SET_MEMORY_INFO_NAME(GetNameInfoReqWrap)
223
  SET_SELF_SIZE(GetNameInfoReqWrap)
224
};
225
226
struct ResponseData final {
227
  int status;
228
  bool is_host;
229
  SafeHostEntPointer host;
230
  MallocedBuffer<unsigned char> buf;
231
};
232
233
template <typename Traits>
234
class QueryWrap final : public AsyncWrap {
235
 public:
236
  QueryWrap(ChannelWrap* channel, v8::Local<v8::Object> req_wrap_obj)
237
0
      : AsyncWrap(channel->env(), req_wrap_obj, AsyncWrap::PROVIDER_QUERYWRAP),
238
0
        channel_(channel),
239
0
        trace_name_(Traits::name) {}
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ReverseTraits>::QueryWrap(node::cares_wrap::ChannelWrap*, v8::Local<v8::Object>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ATraits>::QueryWrap(node::cares_wrap::ChannelWrap*, v8::Local<v8::Object>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AnyTraits>::QueryWrap(node::cares_wrap::ChannelWrap*, v8::Local<v8::Object>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AaaaTraits>::QueryWrap(node::cares_wrap::ChannelWrap*, v8::Local<v8::Object>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CaaTraits>::QueryWrap(node::cares_wrap::ChannelWrap*, v8::Local<v8::Object>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CnameTraits>::QueryWrap(node::cares_wrap::ChannelWrap*, v8::Local<v8::Object>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::MxTraits>::QueryWrap(node::cares_wrap::ChannelWrap*, v8::Local<v8::Object>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NaptrTraits>::QueryWrap(node::cares_wrap::ChannelWrap*, v8::Local<v8::Object>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NsTraits>::QueryWrap(node::cares_wrap::ChannelWrap*, v8::Local<v8::Object>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::PtrTraits>::QueryWrap(node::cares_wrap::ChannelWrap*, v8::Local<v8::Object>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SrvTraits>::QueryWrap(node::cares_wrap::ChannelWrap*, v8::Local<v8::Object>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SoaTraits>::QueryWrap(node::cares_wrap::ChannelWrap*, v8::Local<v8::Object>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TlsaTraits>::QueryWrap(node::cares_wrap::ChannelWrap*, v8::Local<v8::Object>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TxtTraits>::QueryWrap(node::cares_wrap::ChannelWrap*, v8::Local<v8::Object>)
240
241
0
  ~QueryWrap() {
242
0
    CHECK_EQ(false, persistent().IsEmpty());
243
244
    // Let Callback() know that this object no longer exists.
245
0
    if (callback_ptr_ != nullptr)
246
0
      *callback_ptr_ = nullptr;
247
0
  }
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ReverseTraits>::~QueryWrap()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ATraits>::~QueryWrap()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AnyTraits>::~QueryWrap()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AaaaTraits>::~QueryWrap()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CaaTraits>::~QueryWrap()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CnameTraits>::~QueryWrap()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::MxTraits>::~QueryWrap()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NaptrTraits>::~QueryWrap()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NsTraits>::~QueryWrap()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::PtrTraits>::~QueryWrap()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SrvTraits>::~QueryWrap()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SoaTraits>::~QueryWrap()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TlsaTraits>::~QueryWrap()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TxtTraits>::~QueryWrap()
248
249
0
  int Send(const char* name) {
250
0
    return Traits::Send(this, name);
251
0
  }
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ReverseTraits>::Send(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ATraits>::Send(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AnyTraits>::Send(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AaaaTraits>::Send(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CaaTraits>::Send(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CnameTraits>::Send(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::MxTraits>::Send(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NaptrTraits>::Send(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NsTraits>::Send(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::PtrTraits>::Send(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SrvTraits>::Send(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SoaTraits>::Send(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TlsaTraits>::Send(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TxtTraits>::Send(char const*)
252
253
  void AresQuery(const char* name,
254
                 ares_dns_class_t dnsclass,
255
0
                 ares_dns_rec_type_t type) {
256
0
    permission::PermissionScope scope = permission::PermissionScope::kNet;
257
0
    Environment* env_holder = env();
258
259
0
    if (!env_holder->permission()->is_granted(env_holder, scope, name))
260
0
        [[unlikely]] {
261
0
      QueuePermissionModelResponseCallback(name);
262
0
      return;
263
0
    }
264
265
0
    channel_->EnsureServers();
266
0
    TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(
267
0
      TRACING_CATEGORY_NODE2(dns, native), trace_name_, this,
268
0
      "name", TRACE_STR_COPY(name));
269
0
    ares_query_dnsrec(channel_->cares_channel(),
270
0
                      name,
271
0
                      dnsclass,
272
0
                      type,
273
0
                      Callback,
274
0
                      MakeCallbackPointer(),
275
0
                      nullptr);
276
0
  }
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AnyTraits>::AresQuery(char const*, ares_dns_class_t, ares_dns_rec_type_t)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ATraits>::AresQuery(char const*, ares_dns_class_t, ares_dns_rec_type_t)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AaaaTraits>::AresQuery(char const*, ares_dns_class_t, ares_dns_rec_type_t)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CaaTraits>::AresQuery(char const*, ares_dns_class_t, ares_dns_rec_type_t)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CnameTraits>::AresQuery(char const*, ares_dns_class_t, ares_dns_rec_type_t)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::MxTraits>::AresQuery(char const*, ares_dns_class_t, ares_dns_rec_type_t)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NsTraits>::AresQuery(char const*, ares_dns_class_t, ares_dns_rec_type_t)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TlsaTraits>::AresQuery(char const*, ares_dns_class_t, ares_dns_rec_type_t)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TxtTraits>::AresQuery(char const*, ares_dns_class_t, ares_dns_rec_type_t)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SrvTraits>::AresQuery(char const*, ares_dns_class_t, ares_dns_rec_type_t)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::PtrTraits>::AresQuery(char const*, ares_dns_class_t, ares_dns_rec_type_t)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NaptrTraits>::AresQuery(char const*, ares_dns_class_t, ares_dns_rec_type_t)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SoaTraits>::AresQuery(char const*, ares_dns_class_t, ares_dns_rec_type_t)
277
278
  SET_INSUFFICIENT_PERMISSION_ERROR_CALLBACK(permission::PermissionScope::kNet)
279
280
0
  void ParseError(int status) {
281
0
    CHECK_NE(status, ARES_SUCCESS);
282
0
    v8::HandleScope handle_scope(env()->isolate());
283
0
    v8::Context::Scope context_scope(env()->context());
284
0
    const char* code = ToErrorCodeString(status);
285
0
    v8::Local<v8::Value> arg = OneByteString(env()->isolate(), code);
286
0
    TRACE_EVENT_NESTABLE_ASYNC_END1(
287
0
        TRACING_CATEGORY_NODE2(dns, native), trace_name_, this,
288
0
        "error", status);
289
0
    MakeCallback(env()->oncomplete_string(), 1, &arg);
290
0
  }
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AnyTraits>::ParseError(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ATraits>::ParseError(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AaaaTraits>::ParseError(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CaaTraits>::ParseError(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CnameTraits>::ParseError(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::MxTraits>::ParseError(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NsTraits>::ParseError(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TlsaTraits>::ParseError(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TxtTraits>::ParseError(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SrvTraits>::ParseError(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::PtrTraits>::ParseError(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NaptrTraits>::ParseError(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SoaTraits>::ParseError(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ReverseTraits>::ParseError(int)
291
292
0
  const BaseObjectPtr<ChannelWrap>& channel() const { return channel_; }
293
294
0
  void AfterResponse() {
295
0
    CHECK(response_data_);
296
297
0
    int status = response_data_->status;
298
299
0
    if (status != ARES_SUCCESS)
300
0
      return ParseError(status);
301
302
0
    if (!Traits::Parse(this, response_data_).To(&status)) {
303
0
      return ParseError(ARES_ECANCELLED);
304
0
    }
305
306
0
    if (status != ARES_SUCCESS)
307
0
      ParseError(status);
308
0
  }
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AnyTraits>::AfterResponse()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ATraits>::AfterResponse()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AaaaTraits>::AfterResponse()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CaaTraits>::AfterResponse()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CnameTraits>::AfterResponse()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::MxTraits>::AfterResponse()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NsTraits>::AfterResponse()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TlsaTraits>::AfterResponse()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TxtTraits>::AfterResponse()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SrvTraits>::AfterResponse()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::PtrTraits>::AfterResponse()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NaptrTraits>::AfterResponse()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SoaTraits>::AfterResponse()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ReverseTraits>::AfterResponse()
309
310
0
  void* MakeCallbackPointer() {
311
0
    CHECK_NULL(callback_ptr_);
312
0
    callback_ptr_ = new QueryWrap<Traits>*(this);
313
0
    return callback_ptr_;
314
0
  }
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AnyTraits>::MakeCallbackPointer()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ATraits>::MakeCallbackPointer()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AaaaTraits>::MakeCallbackPointer()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CaaTraits>::MakeCallbackPointer()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CnameTraits>::MakeCallbackPointer()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::MxTraits>::MakeCallbackPointer()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NsTraits>::MakeCallbackPointer()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TlsaTraits>::MakeCallbackPointer()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TxtTraits>::MakeCallbackPointer()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SrvTraits>::MakeCallbackPointer()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::PtrTraits>::MakeCallbackPointer()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NaptrTraits>::MakeCallbackPointer()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SoaTraits>::MakeCallbackPointer()
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ReverseTraits>::MakeCallbackPointer()
315
316
0
  static QueryWrap<Traits>* FromCallbackPointer(void* arg) {
317
0
    std::unique_ptr<QueryWrap<Traits>*> wrap_ptr {
318
0
        static_cast<QueryWrap<Traits>**>(arg)
319
0
    };
320
0
    QueryWrap<Traits>* wrap = *wrap_ptr.get();
321
0
    if (wrap == nullptr) return nullptr;
322
0
    wrap->callback_ptr_ = nullptr;
323
0
    return wrap;
324
0
  }
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AnyTraits>::FromCallbackPointer(void*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ATraits>::FromCallbackPointer(void*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AaaaTraits>::FromCallbackPointer(void*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CaaTraits>::FromCallbackPointer(void*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CnameTraits>::FromCallbackPointer(void*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::MxTraits>::FromCallbackPointer(void*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NsTraits>::FromCallbackPointer(void*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TlsaTraits>::FromCallbackPointer(void*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TxtTraits>::FromCallbackPointer(void*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SrvTraits>::FromCallbackPointer(void*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::PtrTraits>::FromCallbackPointer(void*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NaptrTraits>::FromCallbackPointer(void*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SoaTraits>::FromCallbackPointer(void*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ReverseTraits>::FromCallbackPointer(void*)
325
326
  static void Callback(void* arg,
327
                       ares_status_t status,
328
                       size_t timeouts,
329
0
                       const ares_dns_record_t* dnsrec) {
330
0
    QueryWrap<Traits>* wrap = FromCallbackPointer(arg);
331
0
    if (wrap == nullptr) return;
332
333
0
    unsigned char* buf_copy = nullptr;
334
0
    size_t answer_len = 0;
335
0
    if (status == ARES_SUCCESS) {
336
      // No need to explicitly call ares_free_string here,
337
      // as it is a wrapper around free, which is already
338
      // invoked when MallocedBuffer is destructed.
339
0
      ares_dns_write(dnsrec, &buf_copy, &answer_len);
340
0
    }
341
342
0
    wrap->response_data_ = std::make_unique<ResponseData>();
343
0
    ResponseData* data = wrap->response_data_.get();
344
0
    data->status = status;
345
0
    data->is_host = false;
346
0
    data->buf = MallocedBuffer<unsigned char>(buf_copy, answer_len);
347
348
0
    wrap->QueueResponseCallback(status);
349
0
  }
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AnyTraits>::Callback(void*, ares_status_t, unsigned long, ares_dns_record const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ATraits>::Callback(void*, ares_status_t, unsigned long, ares_dns_record const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AaaaTraits>::Callback(void*, ares_status_t, unsigned long, ares_dns_record const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CaaTraits>::Callback(void*, ares_status_t, unsigned long, ares_dns_record const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CnameTraits>::Callback(void*, ares_status_t, unsigned long, ares_dns_record const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::MxTraits>::Callback(void*, ares_status_t, unsigned long, ares_dns_record const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NsTraits>::Callback(void*, ares_status_t, unsigned long, ares_dns_record const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TlsaTraits>::Callback(void*, ares_status_t, unsigned long, ares_dns_record const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TxtTraits>::Callback(void*, ares_status_t, unsigned long, ares_dns_record const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SrvTraits>::Callback(void*, ares_status_t, unsigned long, ares_dns_record const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::PtrTraits>::Callback(void*, ares_status_t, unsigned long, ares_dns_record const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NaptrTraits>::Callback(void*, ares_status_t, unsigned long, ares_dns_record const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SoaTraits>::Callback(void*, ares_status_t, unsigned long, ares_dns_record const*)
350
351
  static void Callback(
352
      void* arg,
353
      int status,
354
      int timeouts,
355
0
      struct hostent* host) {
356
0
    QueryWrap<Traits>* wrap = FromCallbackPointer(arg);
357
0
    if (wrap == nullptr) return;
358
359
0
    struct hostent* host_copy = nullptr;
360
0
    if (status == ARES_SUCCESS) {
361
0
      host_copy = node::Malloc<hostent>(1);
362
0
      cares_wrap_hostent_cpy(host_copy, host);
363
0
    }
364
365
0
    wrap->response_data_ = std::make_unique<ResponseData>();
366
0
    ResponseData* data = wrap->response_data_.get();
367
0
    data->status = status;
368
0
    data->host.reset(host_copy);
369
0
    data->is_host = true;
370
371
0
    wrap->QueueResponseCallback(status);
372
0
  }
373
374
0
  void QueuePermissionModelResponseCallback(const char* resource) {
375
0
    BaseObjectPtr<QueryWrap<Traits>> strong_ref{this};
376
0
    const std::string res{resource};
377
0
    env()->SetImmediate([this, strong_ref, res](Environment*) {
378
0
      InsufficientPermissionError(res);
379
380
      // Delete once strong_ref goes out of scope.
381
0
      Detach();
382
0
    });
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AnyTraits>::QueuePermissionModelResponseCallback(char const*)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ATraits>::QueuePermissionModelResponseCallback(char const*)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AaaaTraits>::QueuePermissionModelResponseCallback(char const*)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CaaTraits>::QueuePermissionModelResponseCallback(char const*)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CnameTraits>::QueuePermissionModelResponseCallback(char const*)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::MxTraits>::QueuePermissionModelResponseCallback(char const*)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NsTraits>::QueuePermissionModelResponseCallback(char const*)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TlsaTraits>::QueuePermissionModelResponseCallback(char const*)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TxtTraits>::QueuePermissionModelResponseCallback(char const*)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SrvTraits>::QueuePermissionModelResponseCallback(char const*)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::PtrTraits>::QueuePermissionModelResponseCallback(char const*)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NaptrTraits>::QueuePermissionModelResponseCallback(char const*)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SoaTraits>::QueuePermissionModelResponseCallback(char const*)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ReverseTraits>::QueuePermissionModelResponseCallback(char const*)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
383
384
0
    channel_->set_query_last_ok(true);
385
0
    channel_->ModifyActivityQueryCount(-1);
386
0
  }
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AnyTraits>::QueuePermissionModelResponseCallback(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ATraits>::QueuePermissionModelResponseCallback(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AaaaTraits>::QueuePermissionModelResponseCallback(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CaaTraits>::QueuePermissionModelResponseCallback(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CnameTraits>::QueuePermissionModelResponseCallback(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::MxTraits>::QueuePermissionModelResponseCallback(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NsTraits>::QueuePermissionModelResponseCallback(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TlsaTraits>::QueuePermissionModelResponseCallback(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TxtTraits>::QueuePermissionModelResponseCallback(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SrvTraits>::QueuePermissionModelResponseCallback(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::PtrTraits>::QueuePermissionModelResponseCallback(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NaptrTraits>::QueuePermissionModelResponseCallback(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SoaTraits>::QueuePermissionModelResponseCallback(char const*)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ReverseTraits>::QueuePermissionModelResponseCallback(char const*)
387
388
0
  void QueueResponseCallback(int status) {
389
0
    BaseObjectPtr<QueryWrap<Traits>> strong_ref{this};
390
0
    env()->SetImmediate([this, strong_ref](Environment*) {
391
0
      AfterResponse();
392
393
      // Delete once strong_ref goes out of scope.
394
0
      Detach();
395
0
    });
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AnyTraits>::QueueResponseCallback(int)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ATraits>::QueueResponseCallback(int)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AaaaTraits>::QueueResponseCallback(int)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CaaTraits>::QueueResponseCallback(int)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CnameTraits>::QueueResponseCallback(int)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::MxTraits>::QueueResponseCallback(int)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NsTraits>::QueueResponseCallback(int)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TlsaTraits>::QueueResponseCallback(int)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TxtTraits>::QueueResponseCallback(int)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SrvTraits>::QueueResponseCallback(int)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::PtrTraits>::QueueResponseCallback(int)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NaptrTraits>::QueueResponseCallback(int)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SoaTraits>::QueueResponseCallback(int)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ReverseTraits>::QueueResponseCallback(int)::{lambda(node::Environment*)#1}::operator()(node::Environment*) const
396
397
0
    channel_->set_query_last_ok(status != ARES_ECONNREFUSED);
398
0
    channel_->ModifyActivityQueryCount(-1);
399
0
  }
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AnyTraits>::QueueResponseCallback(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ATraits>::QueueResponseCallback(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AaaaTraits>::QueueResponseCallback(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CaaTraits>::QueueResponseCallback(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CnameTraits>::QueueResponseCallback(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::MxTraits>::QueueResponseCallback(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NsTraits>::QueueResponseCallback(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TlsaTraits>::QueueResponseCallback(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TxtTraits>::QueueResponseCallback(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SrvTraits>::QueueResponseCallback(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::PtrTraits>::QueueResponseCallback(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NaptrTraits>::QueueResponseCallback(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SoaTraits>::QueueResponseCallback(int)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ReverseTraits>::QueueResponseCallback(int)
400
401
  void CallOnComplete(
402
      v8::Local<v8::Value> answer,
403
0
      v8::Local<v8::Value> extra = v8::Local<v8::Value>()) {
404
0
    v8::HandleScope handle_scope(env()->isolate());
405
0
    v8::Context::Scope context_scope(env()->context());
406
0
    v8::Local<v8::Value> argv[] = {
407
0
      v8::Integer::New(env()->isolate(), 0),
408
0
      answer,
409
0
      extra
410
0
    };
411
0
    const int argc = arraysize(argv) - extra.IsEmpty();
412
0
    TRACE_EVENT_NESTABLE_ASYNC_END0(
413
0
        TRACING_CATEGORY_NODE2(dns, native), trace_name_, this);
414
415
0
    MakeCallback(env()->oncomplete_string(), argc, argv);
416
0
  }
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AnyTraits>::CallOnComplete(v8::Local<v8::Value>, v8::Local<v8::Value>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ATraits>::CallOnComplete(v8::Local<v8::Value>, v8::Local<v8::Value>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AaaaTraits>::CallOnComplete(v8::Local<v8::Value>, v8::Local<v8::Value>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CaaTraits>::CallOnComplete(v8::Local<v8::Value>, v8::Local<v8::Value>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CnameTraits>::CallOnComplete(v8::Local<v8::Value>, v8::Local<v8::Value>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::MxTraits>::CallOnComplete(v8::Local<v8::Value>, v8::Local<v8::Value>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NsTraits>::CallOnComplete(v8::Local<v8::Value>, v8::Local<v8::Value>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TlsaTraits>::CallOnComplete(v8::Local<v8::Value>, v8::Local<v8::Value>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TxtTraits>::CallOnComplete(v8::Local<v8::Value>, v8::Local<v8::Value>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SrvTraits>::CallOnComplete(v8::Local<v8::Value>, v8::Local<v8::Value>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::PtrTraits>::CallOnComplete(v8::Local<v8::Value>, v8::Local<v8::Value>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NaptrTraits>::CallOnComplete(v8::Local<v8::Value>, v8::Local<v8::Value>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SoaTraits>::CallOnComplete(v8::Local<v8::Value>, v8::Local<v8::Value>)
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ReverseTraits>::CallOnComplete(v8::Local<v8::Value>, v8::Local<v8::Value>)
417
418
0
  void MemoryInfo(MemoryTracker* tracker) const override {
419
0
    tracker->TrackField("channel", channel_);
420
0
    if (response_data_) {
421
0
      tracker->TrackFieldWithSize("response", response_data_->buf.size);
422
0
    }
423
0
  }
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ReverseTraits>::MemoryInfo(node::MemoryTracker*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::ATraits>::MemoryInfo(node::MemoryTracker*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AnyTraits>::MemoryInfo(node::MemoryTracker*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::AaaaTraits>::MemoryInfo(node::MemoryTracker*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CaaTraits>::MemoryInfo(node::MemoryTracker*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::CnameTraits>::MemoryInfo(node::MemoryTracker*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::MxTraits>::MemoryInfo(node::MemoryTracker*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NaptrTraits>::MemoryInfo(node::MemoryTracker*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::NsTraits>::MemoryInfo(node::MemoryTracker*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::PtrTraits>::MemoryInfo(node::MemoryTracker*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SrvTraits>::MemoryInfo(node::MemoryTracker*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::SoaTraits>::MemoryInfo(node::MemoryTracker*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TlsaTraits>::MemoryInfo(node::MemoryTracker*) const
Unexecuted instantiation: node::cares_wrap::QueryWrap<node::cares_wrap::TxtTraits>::MemoryInfo(node::MemoryTracker*) const
424
425
  SET_MEMORY_INFO_NAME(QueryWrap)
426
  SET_SELF_SIZE(QueryWrap<Traits>)
427
428
 private:
429
  BaseObjectPtr<ChannelWrap> channel_;
430
431
  std::unique_ptr<ResponseData> response_data_;
432
  const char* trace_name_;
433
  // Pointer to pointer to 'this' that can be reset from the destructor,
434
  // in order to let Callback() know that 'this' no longer exists.
435
  QueryWrap<Traits>** callback_ptr_ = nullptr;
436
};
437
438
#define QUERY_TYPES(V)                                                         \
439
0
  V(Reverse, reverse, getHostByAddr)                                           \
440
0
  V(A, resolve4, queryA)                                                       \
441
0
  V(Any, resolveAny, queryAny)                                                 \
442
0
  V(Aaaa, resolve6, queryAaaa)                                                 \
443
0
  V(Caa, resolveCaa, queryCaa)                                                 \
444
0
  V(Cname, resolveCname, queryCname)                                           \
445
0
  V(Mx, resolveMx, queryMx)                                                    \
446
0
  V(Naptr, resolveNaptr, queryNaptr)                                           \
447
0
  V(Ns, resolveNs, queryNs)                                                    \
448
0
  V(Ptr, resolvePtr, queryPtr)                                                 \
449
0
  V(Srv, resolveSrv, querySrv)                                                 \
450
0
  V(Soa, resolveSoa, querySoa)                                                 \
451
0
  V(Tlsa, resolveTlsa, queryTlsa)                                              \
452
0
  V(Txt, resolveTxt, queryTxt)
453
454
// All query type handlers share the same basic structure, so we can simplify
455
// the code a bit by using a macro to define that structure.
456
#define TYPE_TRAITS(Name, label)                                               \
457
  struct Name##Traits final {                                                  \
458
    static constexpr const char* name = #label;                                \
459
    static int Send(QueryWrap<Name##Traits>* wrap, const char* name);          \
460
    static v8::Maybe<int> Parse(                                               \
461
        QueryWrap<Name##Traits>* wrap,                                         \
462
        const std::unique_ptr<ResponseData>& response);                        \
463
  };                                                                           \
464
  using Query##Name##Wrap = QueryWrap<Name##Traits>;
465
466
#define V(NAME, LABEL, _) TYPE_TRAITS(NAME, LABEL)
467
QUERY_TYPES(V)
468
#undef V
469
#undef TYPE_TRAITS
470
}  // namespace cares_wrap
471
}  // namespace node
472
473
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
474
475
#endif  // SRC_CARES_WRAP_H_