|
|
@ -86,6 +86,7 @@ static Persistent<String> weight_symbol; |
|
|
|
static Persistent<String> port_symbol; |
|
|
|
static Persistent<String> name_symbol; |
|
|
|
static Persistent<String> callback_symbol; |
|
|
|
static Persistent<String> exchange_symbol; |
|
|
|
|
|
|
|
|
|
|
|
void Cares::Initialize(Handle<Object> target) { |
|
|
@ -105,12 +106,14 @@ void Cares::Initialize(Handle<Object> target) { |
|
|
|
weight_symbol = NODE_PSYMBOL("weight"); |
|
|
|
port_symbol = NODE_PSYMBOL("port"); |
|
|
|
name_symbol = NODE_PSYMBOL("name"); |
|
|
|
exchange_symbol = NODE_PSYMBOL("exchange"); |
|
|
|
|
|
|
|
target->Set(String::NewSymbol("AF_INET"), Integer::New(AF_INET)); |
|
|
|
target->Set(String::NewSymbol("AF_INET6"), Integer::New(AF_INET6)); |
|
|
|
|
|
|
|
target->Set(String::NewSymbol("A"), Integer::New(ns_t_a)); |
|
|
|
target->Set(String::NewSymbol("AAAA"), Integer::New(ns_t_aaaa)); |
|
|
|
target->Set(String::NewSymbol("MX"), Integer::New(ns_t_mx)); |
|
|
|
target->Set(String::NewSymbol("NS"), Integer::New(ns_t_ns)); |
|
|
|
target->Set(String::NewSymbol("PTR"), Integer::New(ns_t_ptr)); |
|
|
|
target->Set(String::NewSymbol("TXT"), Integer::New(ns_t_txt)); |
|
|
@ -288,6 +291,34 @@ static void ParseAnswerAAAA(QueryArg *arg, unsigned char* abuf, int alen) { |
|
|
|
cb_call(arg->js_cb, 2, argv); |
|
|
|
} |
|
|
|
|
|
|
|
static void ParseAnswerMX(QueryArg *arg, unsigned char* abuf, int alen) { |
|
|
|
HandleScope scope; |
|
|
|
|
|
|
|
struct ares_mx_reply *mx_out; |
|
|
|
|
|
|
|
int status = ares_parse_mx_reply(abuf, alen, &mx_out); |
|
|
|
if (status != ARES_SUCCESS) { |
|
|
|
ResolveError(arg->js_cb, status); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
Local<Array> mx_records = Array::New(); |
|
|
|
|
|
|
|
struct ares_mx_reply *current = mx_out; |
|
|
|
for (int i = 0; current; ++i, current = current->next) { |
|
|
|
Local<Object> mx = Object::New(); |
|
|
|
|
|
|
|
mx->Set(priority_symbol, Integer::New(current->priority)); |
|
|
|
mx->Set(exchange_symbol, String::New(current->host)); |
|
|
|
|
|
|
|
mx_records->Set(Integer::New(i), mx); |
|
|
|
} |
|
|
|
ares_free_data(mx_out); |
|
|
|
|
|
|
|
Local<Value> argv[2] = { Local<Value>::New(Null()), mx_records }; |
|
|
|
cb_call(arg->js_cb, 2, argv); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void ParseAnswerNS(QueryArg *arg, unsigned char* abuf, int alen) { |
|
|
|
HandleScope scope; |
|
|
@ -471,6 +502,10 @@ Handle<Value> Channel::Query(const Arguments& args) { |
|
|
|
parse_cb = ParseAnswerAAAA; |
|
|
|
break; |
|
|
|
|
|
|
|
case ns_t_mx: |
|
|
|
parse_cb = ParseAnswerMX; |
|
|
|
break; |
|
|
|
|
|
|
|
case ns_t_ns: |
|
|
|
parse_cb = ParseAnswerNS; |
|
|
|
break; |
|
|
|