fix: dns
This commit is contained in:
@ -6,8 +6,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
||||||
int dns_lookup(char *ip_addr, const char *hostname,
|
int dns_lookup(char *ip_addr, const char *hostname)
|
||||||
struct sockaddr_in *addr_con)
|
|
||||||
{
|
{
|
||||||
struct hostent *host = gethostbyname2(hostname, AF_INET);
|
struct hostent *host = gethostbyname2(hostname, AF_INET);
|
||||||
if (!host) {
|
if (!host) {
|
||||||
@ -17,9 +16,6 @@ int dns_lookup(char *ip_addr, const char *hostname,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
strcpy(ip_addr, inet_ntoa(*(struct in_addr *)host->h_addr));
|
strcpy(ip_addr, inet_ntoa(*(struct in_addr *)host->h_addr));
|
||||||
(*addr_con).sin_family = host->h_addrtype;
|
|
||||||
(*addr_con).sin_port = htons(0);
|
|
||||||
(*addr_con).sin_addr.s_addr = *(long *)host->h_addr;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user