Permalink
Browse files

dns, bugfix: fix ipv6 address error.

  • Loading branch information...
xicilion committed Dec 27, 2017
1 parent 02992c4 commit 19763e62536738c472277283d2f0a4bdad685f0b
Showing with 9 additions and 3 deletions.
  1. +8 −0 fibjs/include/inetAddr.h
  2. +1 −3 fibjs/src/net/net.cpp
View
@@ -42,6 +42,14 @@ union inetAddr {
addr6.sin6_family = PF_INET6;
}
void init(sockaddr* addr)
{
if (addr->sa_family == PF_INET)
memmove(this, addr, sizeof(addr4));
else
memmove(this, addr, sizeof(addr6));
}
void setPort(int32_t port)
{
addr4.sin_port = htons(port);
View
@@ -37,9 +37,7 @@ result_t dns_base::resolve(exlib::string name, obj_ptr<NArray>& retVal, AsyncEve
obj_ptr<NArray> arr = new NArray();
for (ptr = result; ptr != NULL; ptr = ptr->ai_next) {
inetAddr addr_info;
addr_info.init(addr_info.addr4.sin_family);
memcpy(&addr_info, ptr->ai_addr, addr_info.size());
addr_info.init(ptr->ai_addr);
arr->append(addr_info.str());
}

0 comments on commit 19763e6

Please sign in to comment.