diff options
-rw-r--r-- | testing/nTox.c | 27 | ||||
-rw-r--r-- | testing/nTox.h | 1 |
2 files changed, 2 insertions, 26 deletions
diff --git a/testing/nTox.c b/testing/nTox.c index 5fdbfd21..068d0317 100644 --- a/testing/nTox.c +++ b/testing/nTox.c | |||
@@ -35,31 +35,6 @@ unsigned char * hex_string_to_bin(char hex_string[]) | |||
35 | return val; | 35 | return val; |
36 | } | 36 | } |
37 | 37 | ||
38 | int resolve_dnsaddr(char *address, char *port) | ||
39 | { | ||
40 | in_addr_t resolved = 0; | ||
41 | resolved = inet_addr(address); | ||
42 | if (resolved != -1) | ||
43 | { | ||
44 | return resolved; | ||
45 | } | ||
46 | |||
47 | struct addrinfo hints; | ||
48 | memset(&hints, 0, sizeof(hints)); | ||
49 | hints.ai_family = AF_INET; | ||
50 | hints.ai_socktype = SOCK_STREAM; | ||
51 | struct addrinfo *server = NULL; | ||
52 | int success = getaddrinfo(address, port, &hints, &server); | ||
53 | if (success != 0) { | ||
54 | printf("failed to resolve %s: %s\n", address, gai_strerror(success)); | ||
55 | return -1; | ||
56 | } else { | ||
57 | resolved = ((struct sockaddr_in*)server->ai_addr)->sin_addr.s_addr; | ||
58 | freeaddrinfo(server); | ||
59 | return resolved; | ||
60 | } | ||
61 | } | ||
62 | |||
63 | void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) | 38 | void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) |
64 | { | 39 | { |
65 | if (line[0] == '/') { | 40 | if (line[0] == '/') { |
@@ -270,7 +245,7 @@ int main(int argc, char *argv[]) | |||
270 | strcpy(line, ""); | 245 | strcpy(line, ""); |
271 | IP_Port bootstrap_ip_port; | 246 | IP_Port bootstrap_ip_port; |
272 | bootstrap_ip_port.port = htons(atoi(argv[2])); | 247 | bootstrap_ip_port.port = htons(atoi(argv[2])); |
273 | int resolved_address = resolve_dnsaddr(argv[1], argv[2]); | 248 | int resolved_address = resolve_addr(argv[1]); |
274 | if (resolved_address != -1) { | 249 | if (resolved_address != -1) { |
275 | bootstrap_ip_port.ip.i = resolved_address; | 250 | bootstrap_ip_port.ip.i = resolved_address; |
276 | } else { | 251 | } else { |
diff --git a/testing/nTox.h b/testing/nTox.h index 8f8a07d0..fbc5d5c0 100644 --- a/testing/nTox.h +++ b/testing/nTox.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <sys/types.h> | 13 | #include <sys/types.h> |
14 | #include <netdb.h> | 14 | #include <netdb.h> |
15 | #include "../core/Messenger.h" | 15 | #include "../core/Messenger.h" |
16 | #include "../core/network.h" | ||
16 | #define STRING_LENGTH 256 | 17 | #define STRING_LENGTH 256 |
17 | #define HISTORY 50 | 18 | #define HISTORY 50 |
18 | 19 | ||