fix name resolution using gethostbyname

This commit is contained in:
David du Colombier 2015-06-15 22:06:31 +02:00
parent 53021339da
commit 2f8a5a51c2
1 changed files with 8 additions and 1 deletions

9
net.c
View File

@ -128,7 +128,14 @@ netlookup(char *name, unsigned char *ip)
/* BUG - Name resolution blocks. Need a non-blocking DNS. */
taskstate("netlookup");
if((he = gethostbyname(name)) != 0){
ip = (unsigned char*)he->h_addr;
switch(he->h_addrtype) {
case AF_INET:
v4tov6(ip, (unsigned char*)he->h_addr);
break;
case AF_INET6:
memcpy(ip, (unsigned char*)he->h_addr, he->h_length);
break;
}
taskstate("netlookup succeeded");
return 0;
}else if(getaddrinfo(name, NULL, NULL, &result) == 0) {