summaryrefslogtreecommitdiff
path: root/testing/nTox.c
diff options
context:
space:
mode:
Diffstat (limited to 'testing/nTox.c')
-rw-r--r--testing/nTox.c27
1 files changed, 1 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
38int 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
63void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) 38void 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 {