|
@ -68,6 +68,8 @@ Local<Object> AddressToJS(const sockaddr* addr); |
|
|
static Persistent<String> address_sym; |
|
|
static Persistent<String> address_sym; |
|
|
static Persistent<String> port_sym; |
|
|
static Persistent<String> port_sym; |
|
|
static Persistent<String> family_sym; |
|
|
static Persistent<String> family_sym; |
|
|
|
|
|
static Persistent<String> ipv4_sym; |
|
|
|
|
|
static Persistent<String> ipv6_sym; |
|
|
static Persistent<String> buffer_sym; |
|
|
static Persistent<String> buffer_sym; |
|
|
static Persistent<String> oncomplete_sym; |
|
|
static Persistent<String> oncomplete_sym; |
|
|
static Persistent<String> onmessage_sym; |
|
|
static Persistent<String> onmessage_sym; |
|
@ -136,6 +138,8 @@ void UDPWrap::Initialize(Handle<Object> target) { |
|
|
oncomplete_sym = NODE_PSYMBOL("oncomplete"); |
|
|
oncomplete_sym = NODE_PSYMBOL("oncomplete"); |
|
|
onmessage_sym = NODE_PSYMBOL("onmessage"); |
|
|
onmessage_sym = NODE_PSYMBOL("onmessage"); |
|
|
family_sym = NODE_PSYMBOL("family"); |
|
|
family_sym = NODE_PSYMBOL("family"); |
|
|
|
|
|
ipv4_sym = NODE_PSYMBOL("IPv4"); |
|
|
|
|
|
ipv6_sym = NODE_PSYMBOL("IPv6"); |
|
|
|
|
|
|
|
|
Local<FunctionTemplate> t = FunctionTemplate::New(New); |
|
|
Local<FunctionTemplate> t = FunctionTemplate::New(New); |
|
|
t->InstanceTemplate()->SetInternalFieldCount(1); |
|
|
t->InstanceTemplate()->SetInternalFieldCount(1); |
|
@ -449,7 +453,6 @@ Local<Object> AddressToJS(const sockaddr* addr) { |
|
|
const sockaddr_in *a4; |
|
|
const sockaddr_in *a4; |
|
|
const sockaddr_in6 *a6; |
|
|
const sockaddr_in6 *a6; |
|
|
int port; |
|
|
int port; |
|
|
const char *family_name; |
|
|
|
|
|
|
|
|
|
|
|
Local<Object> info = Object::New(); |
|
|
Local<Object> info = Object::New(); |
|
|
|
|
|
|
|
@ -458,20 +461,18 @@ Local<Object> AddressToJS(const sockaddr* addr) { |
|
|
a6 = reinterpret_cast<const sockaddr_in6*>(addr); |
|
|
a6 = reinterpret_cast<const sockaddr_in6*>(addr); |
|
|
uv_inet_ntop(AF_INET6, &a6->sin6_addr, ip, sizeof ip); |
|
|
uv_inet_ntop(AF_INET6, &a6->sin6_addr, ip, sizeof ip); |
|
|
port = ntohs(a6->sin6_port); |
|
|
port = ntohs(a6->sin6_port); |
|
|
family_name = "IPv6"; |
|
|
|
|
|
info->Set(address_sym, String::New(ip)); |
|
|
info->Set(address_sym, String::New(ip)); |
|
|
info->Set(family_sym, String::New(family_name)); |
|
|
|
|
|
info->Set(port_sym, Integer::New(port)); |
|
|
info->Set(port_sym, Integer::New(port)); |
|
|
|
|
|
info->Set(family_sym, ipv6_sym); |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case AF_INET: |
|
|
case AF_INET: |
|
|
a4 = reinterpret_cast<const sockaddr_in*>(addr); |
|
|
a4 = reinterpret_cast<const sockaddr_in*>(addr); |
|
|
uv_inet_ntop(AF_INET, &a4->sin_addr, ip, sizeof ip); |
|
|
uv_inet_ntop(AF_INET, &a4->sin_addr, ip, sizeof ip); |
|
|
port = ntohs(a4->sin_port); |
|
|
port = ntohs(a4->sin_port); |
|
|
family_name = "IPv4"; |
|
|
|
|
|
info->Set(address_sym, String::New(ip)); |
|
|
info->Set(address_sym, String::New(ip)); |
|
|
info->Set(family_sym, String::New(family_name)); |
|
|
|
|
|
info->Set(port_sym, Integer::New(port)); |
|
|
info->Set(port_sym, Integer::New(port)); |
|
|
|
|
|
info->Set(family_sym, ipv4_sym); |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
default: |
|
|
default: |
|
|