diff options
author | irungentoo <irungentoo@gmail.com> | 2013-07-20 15:21:08 -0700 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-07-20 15:21:08 -0700 |
commit | 9eb301e51d0554ab4bb396a4b338717f82b66261 (patch) | |
tree | 500593ee7aa5e26e4fd6125a9248ea5fb6df89a3 /testing/nTox.c | |
parent | 0ec94adea92b43448529cba7a1ea898f2bb22cfb (diff) | |
parent | a1078ef9b3f0236e64e0a6fe4e43b1f5759db238 (diff) |
Merge pull request #68 from nurupo/master
Updated nTox
Diffstat (limited to 'testing/nTox.c')
-rw-r--r-- | testing/nTox.c | 27 |
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 | ||
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 { |