diff options
Diffstat (limited to 'testing')
-rw-r--r-- | testing/DHT_test.c | 53 | ||||
-rw-r--r-- | testing/Lossless_UDP_testclient.c | 33 | ||||
-rw-r--r-- | testing/Lossless_UDP_testserver.c | 20 | ||||
-rw-r--r-- | testing/Messenger_test.c | 34 | ||||
-rw-r--r-- | testing/misc_tools.c | 33 | ||||
-rw-r--r-- | testing/nTox.c | 56 |
6 files changed, 150 insertions, 79 deletions
diff --git a/testing/DHT_test.c b/testing/DHT_test.c index fce9c257..9eab60de 100644 --- a/testing/DHT_test.c +++ b/testing/DHT_test.c | |||
@@ -66,13 +66,11 @@ void print_clientlist(DHT *dht) | |||
66 | } | 66 | } |
67 | 67 | ||
68 | p_ip = dht->close_clientlist[i].ip_port; | 68 | p_ip = dht->close_clientlist[i].ip_port; |
69 | printf("\nIP: %u.%u.%u.%u Port: %u", p_ip.ip.uint8[0], p_ip.ip.uint8[1], p_ip.ip.uint8[2], p_ip.ip.uint8[3], | 69 | printf("\nIP: %s Port: %u", ip_ntoa(&p_ip.ip), ntohs(p_ip.port)); |
70 | ntohs(p_ip.port)); | ||
71 | printf("\nTimestamp: %llu", (long long unsigned int) dht->close_clientlist[i].timestamp); | 70 | printf("\nTimestamp: %llu", (long long unsigned int) dht->close_clientlist[i].timestamp); |
72 | printf("\nLast pinged: %llu\n", (long long unsigned int) dht->close_clientlist[i].last_pinged); | 71 | printf("\nLast pinged: %llu\n", (long long unsigned int) dht->close_clientlist[i].last_pinged); |
73 | p_ip = dht->close_clientlist[i].ret_ip_port; | 72 | p_ip = dht->close_clientlist[i].ret_ip_port; |
74 | printf("OUR IP: %u.%u.%u.%u Port: %u\n", p_ip.ip.uint8[0], p_ip.ip.uint8[1], p_ip.ip.uint8[2], p_ip.ip.uint8[3], | 73 | printf("OUR IP: %s Port: %u\n", ip_ntoa(&p_ip.ip), ntohs(p_ip.port)); |
75 | ntohs(p_ip.port)); | ||
76 | printf("Timestamp: %llu\n", (long long unsigned int) dht->close_clientlist[i].ret_timestamp); | 74 | printf("Timestamp: %llu\n", (long long unsigned int) dht->close_clientlist[i].ret_timestamp); |
77 | } | 75 | } |
78 | } | 76 | } |
@@ -91,9 +89,8 @@ void print_friendlist(DHT *dht) | |||
91 | printf("%c", dht->friends_list[k].client_id[j]); | 89 | printf("%c", dht->friends_list[k].client_id[j]); |
92 | } | 90 | } |
93 | 91 | ||
94 | p_ip = DHT_getfriendip(dht, dht->friends_list[k].client_id); | 92 | int friendok = DHT_getfriendip(dht, dht->friends_list[k].client_id, &p_ip); |
95 | printf("\nIP: %u.%u.%u.%u:%u", p_ip.ip.uint8[0], p_ip.ip.uint8[1], p_ip.ip.uint8[2], p_ip.ip.uint8[3], | 93 | printf("\nIP: %s:%u", ip_ntoa(&p_ip.ip), ntohs(p_ip.port)); |
96 | ntohs(p_ip.port)); | ||
97 | 94 | ||
98 | printf("\nCLIENTS IN LIST:\n\n"); | 95 | printf("\nCLIENTS IN LIST:\n\n"); |
99 | 96 | ||
@@ -108,13 +105,11 @@ void print_friendlist(DHT *dht) | |||
108 | } | 105 | } |
109 | 106 | ||
110 | p_ip = dht->friends_list[k].client_list[i].ip_port; | 107 | p_ip = dht->friends_list[k].client_list[i].ip_port; |
111 | printf("\nIP: %u.%u.%u.%u:%u", p_ip.ip.uint8[0], p_ip.ip.uint8[1], p_ip.ip.uint8[2], p_ip.ip.uint8[3], | 108 | printf("\nIP: %s:%u", ip_ntoa(&p_ip.ip), ntohs(p_ip.port)); |
112 | ntohs(p_ip.port)); | ||
113 | printf("\nTimestamp: %llu", (long long unsigned int) dht->friends_list[k].client_list[i].timestamp); | 109 | printf("\nTimestamp: %llu", (long long unsigned int) dht->friends_list[k].client_list[i].timestamp); |
114 | printf("\nLast pinged: %llu\n", (long long unsigned int) dht->friends_list[k].client_list[i].last_pinged); | 110 | printf("\nLast pinged: %llu\n", (long long unsigned int) dht->friends_list[k].client_list[i].last_pinged); |
115 | p_ip = dht->friends_list[k].client_list[i].ret_ip_port; | 111 | p_ip = dht->friends_list[k].client_list[i].ret_ip_port; |
116 | printf("ret IP: %u.%u.%u.%u:%u\n", p_ip.ip.uint8[0], p_ip.ip.uint8[1], p_ip.ip.uint8[2], p_ip.ip.uint8[3], | 112 | printf("ret IP: %s:%u\n", ip_ntoa(&p_ip.ip), ntohs(p_ip.port)); |
117 | ntohs(p_ip.port)); | ||
118 | printf("Timestamp: %llu\n", (long long unsigned int)dht->friends_list[k].client_list[i].ret_timestamp); | 113 | printf("Timestamp: %llu\n", (long long unsigned int)dht->friends_list[k].client_list[i].ret_timestamp); |
119 | } | 114 | } |
120 | } | 115 | } |
@@ -138,19 +133,25 @@ void printpacket(uint8_t *data, uint32_t length, IP_Port ip_port) | |||
138 | 133 | ||
139 | int main(int argc, char *argv[]) | 134 | int main(int argc, char *argv[]) |
140 | { | 135 | { |
136 | if (argc < 4) { | ||
137 | printf("Usage: %s [--ipv4|--ipv6] ip port public_key\n", argv[0]); | ||
138 | exit(0); | ||
139 | } | ||
140 | |||
141 | /* let user override default by cmdline */ | ||
142 | uint8_t ipv6enabled = TOX_ENABLE_IPV6_DEFAULT; /* x */ | ||
143 | int argvoffset = cmdline_parsefor_ipv46(argc, argv, &ipv6enabled); | ||
144 | if (argvoffset < 0) | ||
145 | exit(1); | ||
146 | |||
141 | //memcpy(self_client_id, "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq", 32); | 147 | //memcpy(self_client_id, "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq", 32); |
142 | /* initialize networking */ | 148 | /* initialize networking */ |
143 | /* bind to ip 0.0.0.0:PORT */ | 149 | /* bind to ip 0.0.0.0:PORT */ |
144 | IP ip; | 150 | IP ip; |
145 | ip.uint32 = 0; | 151 | ip_init(&ip, ipv6enabled); |
146 | 152 | ||
147 | DHT *dht = new_DHT(new_net_crypto(new_networking(ip, PORT))); | 153 | DHT *dht = new_DHT(new_net_crypto(new_networking(ip, PORT))); |
148 | 154 | ||
149 | if (argc < 4) { | ||
150 | printf("usage %s ip port public_key\n", argv[0]); | ||
151 | exit(0); | ||
152 | } | ||
153 | |||
154 | new_keys(dht->c); | 155 | new_keys(dht->c); |
155 | printf("OUR ID: "); | 156 | printf("OUR ID: "); |
156 | uint32_t i; | 157 | uint32_t i; |
@@ -170,16 +171,16 @@ int main(int argc, char *argv[]) | |||
170 | 171 | ||
171 | DHT_addfriend(dht, hex_string_to_bin(temp_id)); | 172 | DHT_addfriend(dht, hex_string_to_bin(temp_id)); |
172 | 173 | ||
173 | |||
174 | perror("Initialization"); | 174 | perror("Initialization"); |
175 | IP_Port bootstrap_ip_port; | 175 | |
176 | bootstrap_ip_port.port = htons(atoi(argv[2])); | 176 | uint16_t port = htons(atoi(argv[argvoffset + 2])); |
177 | /* bootstrap_ip_port.ip.c[0] = 127; | 177 | unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]); |
178 | * bootstrap_ip_port.ip.c[1] = 0; | 178 | int res = DHT_bootstrap_from_address(dht, argv[argvoffset + 1], ipv6enabled, port, binary_string); |
179 | * bootstrap_ip_port.ip.c[2] = 0; | 179 | free(binary_string); |
180 | * bootstrap_ip_port.ip.c[3] = 1; */ | 180 | if (!res) { |
181 | bootstrap_ip_port.ip.uint32 = inet_addr(argv[1]); | 181 | printf("Failed to convert \"%s\" into an IP address. Exiting...\n", argv[argvoffset + 1]); |
182 | DHT_bootstrap(dht, bootstrap_ip_port, hex_string_to_bin(argv[3])); | 182 | return 1; |
183 | } | ||
183 | 184 | ||
184 | /* | 185 | /* |
185 | IP_Port ip_port; | 186 | IP_Port ip_port; |
diff --git a/testing/Lossless_UDP_testclient.c b/testing/Lossless_UDP_testclient.c index d5fb1544..155a412a 100644 --- a/testing/Lossless_UDP_testclient.c +++ b/testing/Lossless_UDP_testclient.c | |||
@@ -34,6 +34,7 @@ | |||
34 | 34 | ||
35 | #include "../toxcore/network.h" | 35 | #include "../toxcore/network.h" |
36 | #include "../toxcore/Lossless_UDP.h" | 36 | #include "../toxcore/Lossless_UDP.h" |
37 | #include "misc_tools.c" | ||
37 | 38 | ||
38 | #ifdef WIN32 | 39 | #ifdef WIN32 |
39 | 40 | ||
@@ -66,8 +67,7 @@ void printpacket(uint8_t *data, uint32_t length, IP_Port ip_port) | |||
66 | 67 | ||
67 | void printip(IP_Port ip_port) | 68 | void printip(IP_Port ip_port) |
68 | { | 69 | { |
69 | printf("\nIP: %u.%u.%u.%u Port: %u", ip_port.ip.uint8[0], ip_port.ip.uint8[1], ip_port.ip.uint8[2], ip_port.ip.uint8[3], | 70 | printf("\nIP: %s Port: %u", ip_ntoa(&ip_port.ip), ntohs(ip_port.port)); |
70 | ntohs(ip_port.port)); | ||
71 | } | 71 | } |
72 | /* | 72 | /* |
73 | void printpackets(Data test) | 73 | void printpackets(Data test) |
@@ -152,30 +152,45 @@ void printconnection(int connection_id) | |||
152 | 152 | ||
153 | int main(int argc, char *argv[]) | 153 | int main(int argc, char *argv[]) |
154 | { | 154 | { |
155 | if (argc < 4) { | 155 | /* let user override default by cmdline */ |
156 | printf("usage: %s ip port filename\n", argv[0]); | 156 | uint8_t ipv6enabled = TOX_ENABLE_IPV6_DEFAULT; /* x */ |
157 | int argvoffset = cmdline_parsefor_ipv46(argc, argv, &ipv6enabled); | ||
158 | if (argvoffset < 0) | ||
159 | exit(1); | ||
160 | |||
161 | if (argc < argvoffset + 4) { | ||
162 | printf("Usage: %s [--ipv4|--ipv6] ip port filename\n", argv[0]); | ||
157 | exit(0); | 163 | exit(0); |
158 | } | 164 | } |
159 | 165 | ||
160 | uint8_t buffer[512]; | 166 | uint8_t buffer[512]; |
161 | int read; | 167 | int read; |
162 | 168 | ||
163 | FILE *file = fopen(argv[3], "rb"); | 169 | FILE *file = fopen(argv[argvoffset + 3], "rb"); |
164 | 170 | ||
165 | if (file == NULL) | 171 | if (file == NULL) { |
172 | printf("Failed to open file \"%s\".\n", argv[argvoffset + 3]); | ||
166 | return 1; | 173 | return 1; |
174 | } | ||
167 | 175 | ||
168 | 176 | ||
169 | /* initialize networking */ | 177 | /* initialize networking */ |
170 | /* bind to ip 0.0.0.0:PORT */ | 178 | /* bind to ip 0.0.0.0:PORT */ |
171 | IP ip; | 179 | IP ip; |
172 | ip.uint32 = 0; | 180 | ip_init(&ip, ipv6enabled); |
181 | |||
173 | Lossless_UDP *ludp = new_lossless_udp(new_networking(ip, PORT)); | 182 | Lossless_UDP *ludp = new_lossless_udp(new_networking(ip, PORT)); |
174 | perror("Initialization"); | 183 | perror("Initialization"); |
184 | |||
175 | IP_Port serverip; | 185 | IP_Port serverip; |
176 | serverip.ip.uint32 = inet_addr(argv[1]); | 186 | ip_init(&serverip.ip, ipv6enabled); |
177 | serverip.port = htons(atoi(argv[2])); | 187 | if (!addr_resolve(argv[argvoffset + 1], &serverip.ip, NULL)) { |
188 | printf("Failed to convert \"%s\" into an IP address.\n", argv[argvoffset + 1]); | ||
189 | return 1; | ||
190 | } | ||
191 | serverip.port = htons(atoi(argv[argvoffset + 2])); | ||
178 | printip(serverip); | 192 | printip(serverip); |
193 | |||
179 | int connection = new_connection(ludp, serverip); | 194 | int connection = new_connection(ludp, serverip); |
180 | uint64_t timer = current_time(); | 195 | uint64_t timer = current_time(); |
181 | 196 | ||
diff --git a/testing/Lossless_UDP_testserver.c b/testing/Lossless_UDP_testserver.c index eb506b3d..0fd4edd9 100644 --- a/testing/Lossless_UDP_testserver.c +++ b/testing/Lossless_UDP_testserver.c | |||
@@ -34,6 +34,7 @@ | |||
34 | 34 | ||
35 | #include "../toxcore/network.h" | 35 | #include "../toxcore/network.h" |
36 | #include "../toxcore/Lossless_UDP.h" | 36 | #include "../toxcore/Lossless_UDP.h" |
37 | #include "misc_tools.c" | ||
37 | 38 | ||
38 | //Sleep function (x = milliseconds) | 39 | //Sleep function (x = milliseconds) |
39 | #ifdef WIN32 | 40 | #ifdef WIN32 |
@@ -147,24 +148,33 @@ void printconnection(int connection_id) | |||
147 | 148 | ||
148 | int main(int argc, char *argv[]) | 149 | int main(int argc, char *argv[]) |
149 | { | 150 | { |
150 | if (argc < 2) { | 151 | /* let user override default by cmdline */ |
151 | printf("usage: %s filename\n", argv[0]); | 152 | uint8_t ipv6enabled = TOX_ENABLE_IPV6_DEFAULT; /* x */ |
153 | int argvoffset = cmdline_parsefor_ipv46(argc, argv, &ipv6enabled); | ||
154 | if (argvoffset < 0) | ||
155 | exit(1); | ||
156 | |||
157 | if (argc < argvoffset + 2) { | ||
158 | printf("Usage: %s [--ipv4|--ipv6] filename\n", argv[0]); | ||
152 | exit(0); | 159 | exit(0); |
153 | } | 160 | } |
154 | 161 | ||
155 | uint8_t buffer[512]; | 162 | uint8_t buffer[512]; |
156 | int read; | 163 | int read; |
157 | 164 | ||
158 | FILE *file = fopen(argv[1], "wb"); | 165 | FILE *file = fopen(argv[argvoffset + 1], "wb"); |
159 | 166 | ||
160 | if (file == NULL) | 167 | if (file == NULL) { |
168 | printf("Failed to open file \"%s\".\n", argv[argvoffset + 1]); | ||
161 | return 1; | 169 | return 1; |
170 | } | ||
162 | 171 | ||
163 | 172 | ||
164 | //initialize networking | 173 | //initialize networking |
165 | //bind to ip 0.0.0.0:PORT | 174 | //bind to ip 0.0.0.0:PORT |
166 | IP ip; | 175 | IP ip; |
167 | ip.uint32 = 0; | 176 | ip_init(&ip, ipv6enabled); |
177 | |||
168 | Lossless_UDP *ludp = new_lossless_udp(new_networking(ip, PORT)); | 178 | Lossless_UDP *ludp = new_lossless_udp(new_networking(ip, PORT)); |
169 | perror("Initialization"); | 179 | perror("Initialization"); |
170 | 180 | ||
diff --git a/testing/Messenger_test.c b/testing/Messenger_test.c index e85a85a2..06f8bdbf 100644 --- a/testing/Messenger_test.c +++ b/testing/Messenger_test.c | |||
@@ -95,27 +95,41 @@ void print_message(Messenger *m, int friendnumber, uint8_t *string, uint16_t len | |||
95 | 95 | ||
96 | int main(int argc, char *argv[]) | 96 | int main(int argc, char *argv[]) |
97 | { | 97 | { |
98 | if (argc < 4 && argc != 2) { | 98 | /* let user override default by cmdline */ |
99 | printf("usage %s ip port public_key (of the DHT bootstrap node)\n or\n %s Save.bak\n", argv[0], argv[0]); | 99 | uint8_t ipv6enabled = TOX_ENABLE_IPV6_DEFAULT; /* x */ |
100 | int argvoffset = cmdline_parsefor_ipv46(argc, argv, &ipv6enabled); | ||
101 | if (argvoffset < 0) | ||
102 | exit(1); | ||
103 | |||
104 | /* with optional --ipvx, now it can be 1-4 arguments... */ | ||
105 | if ((argc != argvoffset + 2) && (argc != argvoffset + 4)) { | ||
106 | printf("Usage: %s [--ipv4|--ipv6] ip port public_key (of the DHT bootstrap node)\n", argv[0]); | ||
107 | printf("or\n"); | ||
108 | printf(" %s [--ipv4|--ipv6] Save.bak (to read Save.bak as state file)\n", argv[0]); | ||
100 | exit(0); | 109 | exit(0); |
101 | } | 110 | } |
102 | 111 | ||
103 | m = initMessenger(); | 112 | m = initMessenger(ipv6enabled); |
104 | 113 | ||
105 | if ( !m ) { | 114 | if ( !m ) { |
106 | fputs("Failed to allocate messenger datastructure\n", stderr); | 115 | fputs("Failed to allocate messenger datastructure\n", stderr); |
107 | exit(0); | 116 | exit(0); |
108 | } | 117 | } |
109 | 118 | ||
110 | if (argc > 3) { | 119 | if (argc == argvoffset + 4) { |
111 | IP_Port bootstrap_ip_port; | 120 | uint16_t port = htons(atoi(argv[argvoffset + 2])); |
112 | bootstrap_ip_port.port = htons(atoi(argv[2])); | 121 | uint8_t *bootstrap_key = hex_string_to_bin(argv[argvoffset + 3]); |
113 | bootstrap_ip_port.ip.uint32 = inet_addr(argv[1]); | 122 | int res = DHT_bootstrap_from_address(m->dht, argv[argvoffset + 1], |
114 | DHT_bootstrap(m->dht, bootstrap_ip_port, hex_string_to_bin(argv[3])); | 123 | ipv6enabled, port, bootstrap_key); |
124 | free(bootstrap_key); | ||
125 | if (!res) { | ||
126 | printf("Failed to convert \"%s\" into an IP address. Exiting...\n", argv[argvoffset + 1]); | ||
127 | exit(1); | ||
128 | } | ||
115 | } else { | 129 | } else { |
116 | FILE *file = fopen(argv[1], "rb"); | 130 | FILE *file = fopen(argv[argvoffset + 1], "rb"); |
117 | |||
118 | if ( file == NULL ) { | 131 | if ( file == NULL ) { |
132 | printf("Failed to open \"%s\" - does it exist?\n", argv[argvoffset + 1]); | ||
119 | return 1; | 133 | return 1; |
120 | } | 134 | } |
121 | 135 | ||
diff --git a/testing/misc_tools.c b/testing/misc_tools.c index c4dce1bb..824200d8 100644 --- a/testing/misc_tools.c +++ b/testing/misc_tools.c | |||
@@ -46,3 +46,36 @@ unsigned char *hex_string_to_bin(char hex_string[]) | |||
46 | 46 | ||
47 | return val; | 47 | return val; |
48 | } | 48 | } |
49 | |||
50 | |||
51 | int cmdline_parsefor_ipv46(int argc, char **argv, uint8_t *ipv6enabled) | ||
52 | { | ||
53 | int argvoffset = 0, argi; | ||
54 | for(argi = 1; argi < argc; argi++) | ||
55 | if (!strncasecmp(argv[argi], "--ipv", 5)) { | ||
56 | if (argv[argi][5] && !argv[argi][6]) { | ||
57 | char c = argv[argi][5]; | ||
58 | if (c == '4') | ||
59 | *ipv6enabled = 0; | ||
60 | else if (c == '6') | ||
61 | *ipv6enabled = 1; | ||
62 | else { | ||
63 | printf("Invalid argument: %s. Try --ipv4 or --ipv6!\n", argv[argi]); | ||
64 | return -1; | ||
65 | } | ||
66 | } | ||
67 | else { | ||
68 | printf("Invalid argument: %s. Try --ipv4 or --ipv6!\n", argv[argi]); | ||
69 | return -1; | ||
70 | } | ||
71 | |||
72 | if (argvoffset != argi - 1) { | ||
73 | printf("Argument must come first: %s.\n", argv[argi]); | ||
74 | return -1; | ||
75 | } | ||
76 | |||
77 | argvoffset++; | ||
78 | } | ||
79 | |||
80 | return argvoffset; | ||
81 | }; | ||
diff --git a/testing/nTox.c b/testing/nTox.c index 438468bd..1e83f507 100644 --- a/testing/nTox.c +++ b/testing/nTox.c | |||
@@ -537,6 +537,17 @@ void print_help(void) | |||
537 | 537 | ||
538 | int main(int argc, char *argv[]) | 538 | int main(int argc, char *argv[]) |
539 | { | 539 | { |
540 | if (argc < 4) { | ||
541 | printf("Usage: %s [--ipv4|--ipv6] IP PORT KEY [-f keyfile]\n", argv[0]); | ||
542 | exit(0); | ||
543 | } | ||
544 | |||
545 | /* let user override default by cmdline */ | ||
546 | uint8_t ipv6enabled = TOX_ENABLE_IPV6_DEFAULT; /* x */ | ||
547 | int argvoffset = cmdline_parsefor_ipv46(argc, argv, &ipv6enabled); | ||
548 | if (argvoffset < 0) | ||
549 | exit(1); | ||
550 | |||
540 | int on = 0; | 551 | int on = 0; |
541 | int c = 0; | 552 | int c = 0; |
542 | int i = 0; | 553 | int i = 0; |
@@ -544,29 +555,18 @@ int main(int argc, char *argv[]) | |||
544 | char idstring[200] = {0}; | 555 | char idstring[200] = {0}; |
545 | Tox *m; | 556 | Tox *m; |
546 | 557 | ||
547 | if (argc < 4) { | 558 | if ((argc == 2) && !strcmp(argv[1], "-h")) { |
548 | printf("[!] Usage: %s [IP] [port] [public_key] <keyfile>\n", argv[0]); | 559 | print_help(); |
549 | exit(0); | 560 | exit(0); |
550 | } | 561 | } |
551 | 562 | ||
552 | for (i = 0; i < argc; i++) { | 563 | /* [-f keyfile] MUST be last two arguments, no point in walking over the list |
553 | if (argv[i] == NULL) { | 564 | * especially not a good idea to accept it anywhere in the middle */ |
554 | break; | 565 | if (argc > argvoffset + 3) |
555 | } else if (argv[i][0] == '-') { | 566 | if (!strcmp(argv[argc - 2], "-f")) |
556 | if (argv[i][1] == 'h') { | 567 | filename = argv[argc - 1]; |
557 | print_help(); | ||
558 | exit(0); | ||
559 | } else if (argv[i][1] == 'f') { | ||
560 | if (argv[i + 1] != NULL) | ||
561 | filename = argv[i + 1]; | ||
562 | else { | ||
563 | fputs("[!] you passed '-f' without giving an argument!\n", stderr); | ||
564 | } | ||
565 | } | ||
566 | } | ||
567 | } | ||
568 | 568 | ||
569 | m = tox_new(); | 569 | m = tox_new(ipv6enabled); |
570 | 570 | ||
571 | if ( !m ) { | 571 | if ( !m ) { |
572 | fputs("Failed to allocate Messenger datastructure", stderr); | 572 | fputs("Failed to allocate Messenger datastructure", stderr); |
@@ -590,20 +590,18 @@ int main(int argc, char *argv[]) | |||
590 | new_lines(idstring); | 590 | new_lines(idstring); |
591 | strcpy(line, ""); | 591 | strcpy(line, ""); |
592 | 592 | ||
593 | tox_IP_Port bootstrap_ip_port; | 593 | uint16_t port = htons(atoi(argv[argvoffset + 2])); |
594 | bootstrap_ip_port.port = htons(atoi(argv[2])); | 594 | unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]); |
595 | int resolved_address = resolve_addr(argv[1]); | 595 | int res = tox_bootstrap_from_address(m, argv[argvoffset + 1], ipv6enabled, port, binary_string); |
596 | free(binary_string); | ||
596 | 597 | ||
597 | if (resolved_address != 0) | 598 | if (!res) { |
598 | bootstrap_ip_port.ip.i = resolved_address; | 599 | printf("Failed to convert \"%s\" into an IP address. Exiting...\n", argv[argvoffset + 1]); |
599 | else | 600 | endwin(); |
600 | exit(1); | 601 | exit(1); |
602 | } | ||
601 | 603 | ||
602 | unsigned char *binary_string = hex_string_to_bin(argv[3]); | ||
603 | tox_bootstrap(m, bootstrap_ip_port, binary_string); | ||
604 | free(binary_string); | ||
605 | nodelay(stdscr, TRUE); | 604 | nodelay(stdscr, TRUE); |
606 | |||
607 | while (1) { | 605 | while (1) { |
608 | if (on == 0 && tox_isconnected(m)) { | 606 | if (on == 0 && tox_isconnected(m)) { |
609 | new_lines("[i] connected to DHT\n[i] define username with /n"); | 607 | new_lines("[i] connected to DHT\n[i] define username with /n"); |