Skip to content
This repository
tree: de21de920c
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 767 lines (599 sloc) 19.266 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

#include <assert.h>
#include <node.h>
#include <req_wrap.h>
#include <uv.h>

#include <string.h>

#if defined(__OpenBSD__) || defined(__MINGW32__) || defined(_MSC_VER)
# include <nameser.h>
#else
# include <arpa/nameser.h>
#endif

// Temporary hack: libuv should provide uv_inet_pton and uv_inet_ntop.
#if defined(__MINGW32__) || defined(_MSC_VER)
  extern "C" {
# include <inet_net_pton.h>
# include <inet_ntop.h>
  }
# define uv_inet_pton ares_inet_pton
# define uv_inet_ntop ares_inet_ntop

#else // __POSIX__
# include <arpa/inet.h>
# define uv_inet_pton inet_pton
# define uv_inet_ntop inet_ntop
#endif


namespace node {

namespace cares_wrap {

using v8::Arguments;
using v8::Array;
using v8::Context;
using v8::Function;
using v8::Handle;
using v8::HandleScope;
using v8::Integer;
using v8::Local;
using v8::Null;
using v8::Object;
using v8::Persistent;
using v8::String;
using v8::Value;


typedef class ReqWrap<uv_getaddrinfo_t> GetAddrInfoReqWrap;

static Persistent<String> oncomplete_sym;

static ares_channel ares_channel;


static Local<Array> HostentToAddresses(struct hostent* host) {
  HandleScope scope;
  Local<Array> addresses = Array::New();

  char ip[INET6_ADDRSTRLEN];
  for (int i = 0; host->h_addr_list[i]; ++i) {
    uv_inet_ntop(host->h_addrtype, host->h_addr_list[i], ip, sizeof(ip));

    Local<String> address = String::New(ip);
    addresses->Set(Integer::New(i), address);
  }

  return scope.Close(addresses);
}


static Local<Array> HostentToNames(struct hostent* host) {
  HandleScope scope;
  Local<Array> names = Array::New();

  for (int i = 0; host->h_aliases[i]; ++i) {
    Local<String> address = String::New(host->h_aliases[i]);
    names->Set(Integer::New(i), address);
  }

  return scope.Close(names);
}


static const char* AresErrnoString(int errorno) {
  switch (errorno) {
#define ERRNO_CASE(e) case ARES_##e: return #e;
    ERRNO_CASE(SUCCESS)
    ERRNO_CASE(ENODATA)
    ERRNO_CASE(EFORMERR)
    ERRNO_CASE(ESERVFAIL)
    ERRNO_CASE(ENOTFOUND)
    ERRNO_CASE(ENOTIMP)
    ERRNO_CASE(EREFUSED)
    ERRNO_CASE(EBADQUERY)
    ERRNO_CASE(EBADNAME)
    ERRNO_CASE(EBADFAMILY)
    ERRNO_CASE(EBADRESP)
    ERRNO_CASE(ECONNREFUSED)
    ERRNO_CASE(ETIMEOUT)
    ERRNO_CASE(EOF)
    ERRNO_CASE(EFILE)
    ERRNO_CASE(ENOMEM)
    ERRNO_CASE(EDESTRUCTION)
    ERRNO_CASE(EBADSTR)
    ERRNO_CASE(EBADFLAGS)
    ERRNO_CASE(ENONAME)
    ERRNO_CASE(EBADHINTS)
    ERRNO_CASE(ENOTINITIALIZED)
    ERRNO_CASE(ELOADIPHLPAPI)
    ERRNO_CASE(EADDRGETNETWORKPARAMS)
    ERRNO_CASE(ECANCELLED)
#undef ERRNO_CASE
    default:
      assert(0 && "Unhandled c-ares error");
      return "(UNKNOWN)";
  }
}


static void SetAresErrno(int errorno) {
  HandleScope scope;
  Handle<Value> key = String::NewSymbol("errno");
  Handle<Value> value = String::NewSymbol(AresErrnoString(errorno));
  Context::GetCurrent()->Global()->Set(key, value);
}


class QueryWrap {
 public:
  QueryWrap() {
    HandleScope scope;

    object_ = Persistent<Object>::New(Object::New());
  }

  virtual ~QueryWrap() {
    assert(!object_.IsEmpty());

    object_->Delete(oncomplete_sym);

    object_.Dispose();
    object_.Clear();
  }

  Handle<Object> GetObject() {
    return object_;
  }

  void SetOnComplete(Handle<Value> oncomplete) {
    assert(oncomplete->IsFunction());
    object_->Set(oncomplete_sym, oncomplete);
  }

  // Subclasses should implement the appropriate Send method.
  virtual int Send(const char* name) {
    assert(0);
    return 0;
  }

  virtual int Send(const char* name, int family) {
    assert(0);
    return 0;
  }

 protected:
  void* GetQueryArg() {
    return static_cast<void*>(this);
  }

  static void Callback(void *arg, int status, int timeouts,
      unsigned char* answer_buf, int answer_len) {
    QueryWrap* wrap = reinterpret_cast<QueryWrap*>(arg);

    if (status != ARES_SUCCESS) {
      wrap->ParseError(status);
    } else {
      wrap->Parse(answer_buf, answer_len);
    }

    delete wrap;
  }

  static void Callback(void *arg, int status, int timeouts,
      struct hostent* host) {
    QueryWrap* wrap = reinterpret_cast<QueryWrap*>(arg);

    if (status != ARES_SUCCESS) {
      wrap->ParseError(status);
    } else {
      wrap->Parse(host);
    }

    delete wrap;
  }

  void CallOnComplete(Local<Value> answer) {
    HandleScope scope;
    Local<Value> argv[2] = { Integer::New(0), answer };
    MakeCallback(object_, "oncomplete", 2, argv);
  }

  void CallOnComplete(Local<Value> answer, Local<Value> family) {
    HandleScope scope;
    Local<Value> argv[3] = { Integer::New(0), answer, family };
    MakeCallback(object_, "oncomplete", 3, argv);
  }

  void ParseError(int status) {
    assert(status != ARES_SUCCESS);
    SetAresErrno(status);

    HandleScope scope;
    Local<Value> argv[1] = { Integer::New(-1) };
    MakeCallback(object_, "oncomplete", 1, argv);
  }

  // Subclasses should implement the appropriate Parse method.
  virtual void Parse(unsigned char* buf, int len) {
    assert(0);
  };

  virtual void Parse(struct hostent* host) {
    assert(0);
  };

 private:
  Persistent<Object> object_;
};


class QueryAWrap: public QueryWrap {
 public:
  int Send(const char* name) {
    ares_query(ares_channel, name, ns_c_in, ns_t_a, Callback, GetQueryArg());
    return 0;
  }

 protected:
  void Parse(unsigned char* buf, int len) {
    HandleScope scope;

    struct hostent* host;

    int status = ares_parse_a_reply(buf, len, &host, NULL, NULL);
    if (status != ARES_SUCCESS) {
      this->ParseError(status);
      return;
    }

    Local<Array> addresses = HostentToAddresses(host);
    ares_free_hostent(host);

    this->CallOnComplete(addresses);
  }
};


class QueryAaaaWrap: public QueryWrap {
 public:
  int Send(const char* name) {
    ares_query(ares_channel,
               name,
               ns_c_in,
               ns_t_aaaa,
               Callback,
               GetQueryArg());
    return 0;
  }

 protected:
  void Parse(unsigned char* buf, int len) {
    HandleScope scope;

    struct hostent* host;

    int status = ares_parse_aaaa_reply(buf, len, &host, NULL, NULL);
    if (status != ARES_SUCCESS) {
      this->ParseError(status);
      return;
    }

    Local<Array> addresses = HostentToAddresses(host);
    ares_free_hostent(host);

    this->CallOnComplete(addresses);
  }
};


class QueryCnameWrap: public QueryWrap {
 public:
  int Send(const char* name) {
    ares_query(ares_channel,
               name,
               ns_c_in,
               ns_t_cname,
               Callback,
               GetQueryArg());
    return 0;
  }

 protected:
  void Parse(unsigned char* buf, int len) {
    HandleScope scope;

    struct hostent* host;

    int status = ares_parse_a_reply(buf, len, &host, NULL, NULL);
    if (status != ARES_SUCCESS) {
      this->ParseError(status);
      return;
    }

    // A cname lookup always returns a single record but we follow the
    // common API here.
    Local<Array> result = Array::New(1);
    result->Set(0, String::New(host->h_name));
    ares_free_hostent(host);

    this->CallOnComplete(result);
  }
};


class QueryMxWrap: public QueryWrap {
 public:
  int Send(const char* name) {
    ares_query(ares_channel, name, ns_c_in, ns_t_mx, Callback, GetQueryArg());
    return 0;
  }

 protected:
  void Parse(unsigned char* buf, int len) {
    HandleScope scope;

    struct ares_mx_reply* mx_start;
    int status = ares_parse_mx_reply(buf, len, &mx_start);
    if (status != ARES_SUCCESS) {
      this->ParseError(status);
      return;
    }

    Local<Array> mx_records = Array::New();
    Local<String> exchange_symbol = String::NewSymbol("exchange");
    Local<String> priority_symbol = String::NewSymbol("priority");
    int i = 0;
    for (struct ares_mx_reply* mx_current = mx_start;
         mx_current;
         mx_current = mx_current->next) {
      Local<Object> mx_record = Object::New();
      mx_record->Set(exchange_symbol, String::New(mx_current->host));
      mx_record->Set(priority_symbol, Integer::New(mx_current->priority));
      mx_records->Set(Integer::New(i++), mx_record);
    }

    ares_free_data(mx_start);

    this->CallOnComplete(mx_records);
  }
};


class QueryNsWrap: public QueryWrap {
 public:
  int Send(const char* name) {
    ares_query(ares_channel, name, ns_c_in, ns_t_ns, Callback, GetQueryArg());
    return 0;
  }

 protected:
  void Parse(unsigned char* buf, int len) {
    struct hostent* host;

    int status = ares_parse_ns_reply(buf, len, &host);
    if (status != ARES_SUCCESS) {
      this->ParseError(status);
      return;
    }

    Local<Array> names = HostentToNames(host);
    ares_free_hostent(host);

    this->CallOnComplete(names);
  }
};


class QueryTxtWrap: public QueryWrap {
 public:
  int Send(const char* name) {
    ares_query(ares_channel, name, ns_c_in, ns_t_txt, Callback, GetQueryArg());
    return 0;
  }

 protected:
  void Parse(unsigned char* buf, int len) {
    struct ares_txt_reply* txt_out;

    int status = ares_parse_txt_reply(buf, len, &txt_out);
    if (status != ARES_SUCCESS) {
      this->ParseError(status);
      return;
    }

    Local<Array> txt_records = Array::New();

    struct ares_txt_reply *current = txt_out;
    for (int i = 0; current; ++i, current = current->next) {
      Local<String> txt = String::New(reinterpret_cast<char*>(current->txt));
      txt_records->Set(Integer::New(i), txt);
    }

    ares_free_data(txt_out);

    this->CallOnComplete(txt_records);
  }
};


class QuerySrvWrap: public QueryWrap {
 public:
  int Send(const char* name) {
    ares_query(ares_channel,
               name,
               ns_c_in,
               ns_t_srv,
               Callback,
               GetQueryArg());
    return 0;
  }

 protected:
  void Parse(unsigned char* buf, int len) {
    HandleScope scope;

    struct ares_srv_reply* srv_start;
    int status = ares_parse_srv_reply(buf, len, &srv_start);
    if (status != ARES_SUCCESS) {
      this->ParseError(status);
      return;
    }

    Local<Array> srv_records = Array::New();
    Local<String> name_symbol = String::NewSymbol("name");
    Local<String> port_symbol = String::NewSymbol("port");
    Local<String> priority_symbol = String::NewSymbol("priority");
    Local<String> weight_symbol = String::NewSymbol("weight");
    int i = 0;
    for (struct ares_srv_reply* srv_current = srv_start;
         srv_current;
         srv_current = srv_current->next) {
      Local<Object> srv_record = Object::New();
      srv_record->Set(name_symbol, String::New(srv_current->host));
      srv_record->Set(port_symbol, Integer::New(srv_current->port));
      srv_record->Set(priority_symbol, Integer::New(srv_current->priority));
      srv_record->Set(weight_symbol, Integer::New(srv_current->weight));
      srv_records->Set(Integer::New(i++), srv_record);
    }

    ares_free_data(srv_start);

    this->CallOnComplete(srv_records);
  }
};


class GetHostByAddrWrap: public QueryWrap {
 public:
  int Send(const char* name) {
    int length, family;
    char address_buffer[sizeof(struct in6_addr)];

    if (uv_inet_pton(AF_INET, name, &address_buffer) == 1) {
      length = sizeof(struct in_addr);
      family = AF_INET;
    } else if (uv_inet_pton(AF_INET6, name, &address_buffer) == 1) {
      length = sizeof(struct in6_addr);
      family = AF_INET6;
    } else {
      return ARES_ENOTIMP;
    }

    ares_gethostbyaddr(ares_channel,
                       address_buffer,
                       length,
                       family,
                       Callback,
                       GetQueryArg());
    return 0;
  }

 protected:
  void Parse(struct hostent* host) {
    HandleScope scope;

    this->CallOnComplete(HostentToNames(host));
  }
};


class GetHostByNameWrap: public QueryWrap {
 public:
  int Send(const char* name, int family) {
    ares_gethostbyname(ares_channel, name, family, Callback, GetQueryArg());
    return 0;
  }

 protected:
  void Parse(struct hostent* host) {
    HandleScope scope;

    Local<Array> addresses = HostentToAddresses(host);
    Local<Integer> family = Integer::New(host->h_addrtype);

    this->CallOnComplete(addresses, family);
  }
};


template <class Wrap>
static Handle<Value> Query(const Arguments& args) {
  HandleScope scope;

  assert(!args.IsConstructCall());
  assert(args.Length() >= 2);
  assert(args[1]->IsFunction());

  Wrap* wrap = new Wrap();
  wrap->SetOnComplete(args[1]);

  // We must cache the wrap's js object here, because cares might make the
  // callback from the wrap->Send stack. This will destroy the wrap's internal
  // object reference, causing wrap->GetObject() to return undefined.
  Local<Object> object = Local<Object>::New(wrap->GetObject());

  String::Utf8Value name(args[0]->ToString());

  int r = wrap->Send(*name);
  if (r) {
    SetAresErrno(r);
    delete wrap;
    return scope.Close(v8::Null());
  } else {
    return scope.Close(object);
  }
}


template <class Wrap>
static Handle<Value> QueryWithFamily(const Arguments& args) {
  HandleScope scope;

  assert(!args.IsConstructCall());
  assert(args.Length() >= 3);
  assert(args[2]->IsFunction());

  Wrap* wrap = new Wrap();
  wrap->SetOnComplete(args[2]);

  // We must cache the wrap's js object here, because cares might make the
  // callback from the wrap->Send stack. This will destroy the wrap's internal
  // object reference, causing wrap->GetObject() to return undefined.
  Local<Object> object = Local<Object>::New(wrap->GetObject());

  String::Utf8Value name(args[0]->ToString());
  int family = args[1]->Int32Value();

  int r = wrap->Send(*name, family);
  if (r) {
    SetAresErrno(r);
    delete wrap;
    return scope.Close(v8::Null());
  } else {
    return scope.Close(object);
  }
}


void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
  HandleScope scope;

  GetAddrInfoReqWrap* req_wrap = (GetAddrInfoReqWrap*) req->data;

  Local<Value> argv[1];

  if (status) {
    // Error
    SetErrno(uv_last_error(uv_default_loop()));
    argv[0] = Local<Value>::New(Null());
  } else {
    // Success
    struct addrinfo *address;
    int n = 0;

    // Count the number of responses.
    for (address = res; address; address = address->ai_next) {
      n++;
    }

    // Create the response array.
    Local<Array> results = Array::New(n);

    char ip[INET6_ADDRSTRLEN];
    const char *addr;

    n = 0;

    // Iterate over the IPv4 responses again this time creating javascript
    // strings for each IP and filling the results array.
    address = res;
    while (address) {
      assert(address->ai_socktype == SOCK_STREAM);

      // Ignore random ai_family types.
      if (address->ai_family == AF_INET) {
        // Juggle pointers
        addr = (char*) &((struct sockaddr_in*) address->ai_addr)->sin_addr;
        const char* c = uv_inet_ntop(address->ai_family, addr, ip,
            INET6_ADDRSTRLEN);

        // Create JavaScript string
        Local<String> s = String::New(c);
        results->Set(n, s);
        n++;
      }

      // Increment
      address = address->ai_next;
    }

    // Iterate over the IPv6 responses putting them in the array.
    address = res;
    while (address) {
      assert(address->ai_socktype == SOCK_STREAM);

      // Ignore random ai_family types.
      if (address->ai_family == AF_INET6) {
        // Juggle pointers
        addr = (char*) &((struct sockaddr_in6*) address->ai_addr)->sin6_addr;
        const char* c = uv_inet_ntop(address->ai_family, addr, ip,
            INET6_ADDRSTRLEN);

        // Create JavaScript string
        Local<String> s = String::New(c);
        results->Set(n, s);
        n++;
      }

      // Increment
      address = address->ai_next;
    }


    argv[0] = results;
  }

  uv_freeaddrinfo(res);

  // Make the callback into JavaScript
  MakeCallback(req_wrap->object_, "oncomplete", 1, argv);

  delete req_wrap;
}


static Handle<Value> GetAddrInfo(const Arguments& args) {
  HandleScope scope;

  String::Utf8Value hostname(args[0]->ToString());

  int fam = AF_UNSPEC;
  if (args[1]->IsInt32()) {
    switch (args[1]->Int32Value()) {
      case 6:
        fam = AF_INET6;
        break;

      case 4:
        fam = AF_INET;
        break;
    }
  }

  GetAddrInfoReqWrap* req_wrap = new GetAddrInfoReqWrap();

  struct addrinfo hints;
  memset(&hints, 0, sizeof(struct addrinfo));
  hints.ai_family = fam;
  hints.ai_socktype = SOCK_STREAM;

  int r = uv_getaddrinfo(uv_default_loop(),
                         &req_wrap->req_,
                         AfterGetAddrInfo,
                         *hostname,
                         NULL,
                         &hints);
  req_wrap->Dispatched();

  if (r) {
    SetErrno(uv_last_error(uv_default_loop()));
    delete req_wrap;
    return scope.Close(v8::Null());
  } else {
    return scope.Close(req_wrap->object_);
  }
}


static void Initialize(Handle<Object> target) {
  HandleScope scope;
  int r;

  r = ares_library_init(ARES_LIB_INIT_ALL);
  assert(r == ARES_SUCCESS);

  struct ares_options options;
  uv_ares_init_options(uv_default_loop(), &ares_channel, &options, 0);
  assert(r == 0);

  NODE_SET_METHOD(target, "queryA", Query<QueryAWrap>);
  NODE_SET_METHOD(target, "queryAaaa", Query<QueryAaaaWrap>);
  NODE_SET_METHOD(target, "queryCname", Query<QueryCnameWrap>);
  NODE_SET_METHOD(target, "queryMx", Query<QueryMxWrap>);
  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, "getHostByAddr", Query<GetHostByAddrWrap>);
  NODE_SET_METHOD(target, "getHostByName", QueryWithFamily<GetHostByNameWrap>);

  NODE_SET_METHOD(target, "getaddrinfo", GetAddrInfo);

  target->Set(String::NewSymbol("AF_INET"), Integer::New(AF_INET));
  target->Set(String::NewSymbol("AF_INET6"), Integer::New(AF_INET6));
  target->Set(String::NewSymbol("AF_UNSPEC"), Integer::New(AF_UNSPEC));

  oncomplete_sym = Persistent<String>::New(String::NewSymbol("oncomplete"));
}


} // namespace cares_wrap

} // namespace node

NODE_MODULE(node_cares_wrap, node::cares_wrap::Initialize)
Something went wrong with that request. Please try again.