diff options
-rw-r--r-- | auto_tests/messenger_test.c | 4 | ||||
-rw-r--r-- | other/DHT_bootstrap.c | 5 | ||||
-rw-r--r-- | testing/DHT_test.c | 2 | ||||
-rw-r--r-- | testing/Messenger_test.c | 3 | ||||
-rw-r--r-- | testing/nTox.c | 2 | ||||
-rw-r--r-- | toxcore/DHT.c | 13 | ||||
-rw-r--r-- | toxcore/DHT.h | 24 | ||||
-rw-r--r-- | toxcore/LAN_discovery.c | 15 | ||||
-rw-r--r-- | toxcore/network.c | 14 | ||||
-rw-r--r-- | toxcore/tox.c | 6 | ||||
-rw-r--r-- | toxcore/tox.h | 38 | ||||
-rw-r--r-- | toxcore/util.c | 2 |
12 files changed, 94 insertions, 34 deletions
diff --git a/auto_tests/messenger_test.c b/auto_tests/messenger_test.c index 6677c345..1b72a92f 100644 --- a/auto_tests/messenger_test.c +++ b/auto_tests/messenger_test.c | |||
@@ -278,8 +278,8 @@ int main(int argc, char *argv[]) | |||
278 | good_id_b = hex_string_to_bin(good_id_b_str); | 278 | good_id_b = hex_string_to_bin(good_id_b_str); |
279 | bad_id = hex_string_to_bin(bad_id_str); | 279 | bad_id = hex_string_to_bin(bad_id_str); |
280 | 280 | ||
281 | /* no IPv6 enabled yet */ | 281 | /* IPv6 status from global define */ |
282 | m = initMessenger(0); | 282 | m = initMessenger(TOX_ENABLE_IPV6_DEFAULT); |
283 | 283 | ||
284 | /* setup a default friend and friendnum */ | 284 | /* setup a default friend and friendnum */ |
285 | if (m_addfriend_norequest(m, (uint8_t *)friend_id) < 0) | 285 | if (m_addfriend_norequest(m, (uint8_t *)friend_id) < 0) |
diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c index f5fa9818..e6e8d59f 100644 --- a/other/DHT_bootstrap.c +++ b/other/DHT_bootstrap.c | |||
@@ -122,13 +122,14 @@ int main(int argc, char *argv[]) | |||
122 | fclose(file); | 122 | fclose(file); |
123 | 123 | ||
124 | printf("\n"); | 124 | printf("\n"); |
125 | printf("Port: %u\n", PORT); | 125 | printf("Port: %u\n", ntohs(dht->c->lossless_udp->net->port)); |
126 | 126 | ||
127 | if (argc > argvoffset + 3) { | 127 | if (argc > argvoffset + 3) { |
128 | printf("Trying to bootstrap into the network...\n"); | 128 | printf("Trying to bootstrap into the network...\n"); |
129 | uint16_t port = htons(atoi(argv[argvoffset + 2])); | 129 | uint16_t port = htons(atoi(argv[argvoffset + 2])); |
130 | uint8_t *bootstrap_key = hex_string_to_bin(argv[argvoffset + 3]); | 130 | uint8_t *bootstrap_key = hex_string_to_bin(argv[argvoffset + 3]); |
131 | int res = DHT_bootstrap_ex(dht, argv[argvoffset + 1], ipv6enabled, port, bootstrap_key); | 131 | int res = DHT_bootstrap_from_address(dht, argv[argvoffset + 1], |
132 | ipv6enabled, port, bootstrap_key); | ||
132 | free(bootstrap_key); | 133 | free(bootstrap_key); |
133 | 134 | ||
134 | if (!res) { | 135 | if (!res) { |
diff --git a/testing/DHT_test.c b/testing/DHT_test.c index ba8c2f23..9eab60de 100644 --- a/testing/DHT_test.c +++ b/testing/DHT_test.c | |||
@@ -175,7 +175,7 @@ int main(int argc, char *argv[]) | |||
175 | 175 | ||
176 | uint16_t port = htons(atoi(argv[argvoffset + 2])); | 176 | uint16_t port = htons(atoi(argv[argvoffset + 2])); |
177 | unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]); | 177 | unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]); |
178 | int res = DHT_bootstrap_ex(dht, argv[argvoffset + 1], ipv6enabled, port, binary_string); | 178 | int res = DHT_bootstrap_from_address(dht, argv[argvoffset + 1], ipv6enabled, port, binary_string); |
179 | free(binary_string); | 179 | free(binary_string); |
180 | if (!res) { | 180 | if (!res) { |
181 | printf("Failed to convert \"%s\" into an IP address. Exiting...\n", argv[argvoffset + 1]); | 181 | printf("Failed to convert \"%s\" into an IP address. Exiting...\n", argv[argvoffset + 1]); |
diff --git a/testing/Messenger_test.c b/testing/Messenger_test.c index fdcd3061..06f8bdbf 100644 --- a/testing/Messenger_test.c +++ b/testing/Messenger_test.c | |||
@@ -119,7 +119,8 @@ int main(int argc, char *argv[]) | |||
119 | if (argc == argvoffset + 4) { | 119 | if (argc == argvoffset + 4) { |
120 | uint16_t port = htons(atoi(argv[argvoffset + 2])); | 120 | uint16_t port = htons(atoi(argv[argvoffset + 2])); |
121 | uint8_t *bootstrap_key = hex_string_to_bin(argv[argvoffset + 3]); | 121 | uint8_t *bootstrap_key = hex_string_to_bin(argv[argvoffset + 3]); |
122 | int res = DHT_bootstrap_ex(m->dht, argv[argvoffset + 1], ipv6enabled, port, bootstrap_key); | 122 | int res = DHT_bootstrap_from_address(m->dht, argv[argvoffset + 1], |
123 | ipv6enabled, port, bootstrap_key); | ||
123 | free(bootstrap_key); | 124 | free(bootstrap_key); |
124 | if (!res) { | 125 | if (!res) { |
125 | printf("Failed to convert \"%s\" into an IP address. Exiting...\n", argv[argvoffset + 1]); | 126 | printf("Failed to convert \"%s\" into an IP address. Exiting...\n", argv[argvoffset + 1]); |
diff --git a/testing/nTox.c b/testing/nTox.c index 750970f9..9cfa3687 100644 --- a/testing/nTox.c +++ b/testing/nTox.c | |||
@@ -592,7 +592,7 @@ int main(int argc, char *argv[]) | |||
592 | 592 | ||
593 | uint16_t port = htons(atoi(argv[argvoffset + 2])); | 593 | uint16_t port = htons(atoi(argv[argvoffset + 2])); |
594 | unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]); | 594 | unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]); |
595 | int res = tox_bootstrap_ex(m, argv[argvoffset + 1], ipv6enabled, port, binary_string); | 595 | int res = tox_bootstrap_from_address(m, argv[argvoffset + 1], ipv6enabled, port, binary_string); |
596 | free(binary_string); | 596 | free(binary_string); |
597 | 597 | ||
598 | if (!res) { | 598 | if (!res) { |
diff --git a/toxcore/DHT.c b/toxcore/DHT.c index 44f7f101..96bfd663 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c | |||
@@ -617,7 +617,7 @@ static int sendnodes(DHT *dht, IP_Port ip_port, uint8_t *public_key, uint8_t *cl | |||
617 | 617 | ||
618 | #ifdef TOX_ENABLE_IPV6 | 618 | #ifdef TOX_ENABLE_IPV6 |
619 | /* Send a send nodes response: message for IPv6 nodes */ | 619 | /* Send a send nodes response: message for IPv6 nodes */ |
620 | static int sendnodes_ex(DHT *dht, IP_Port ip_port, uint8_t *public_key, uint8_t *client_id, uint64_t ping_id) | 620 | static int sendnodes_ipv6(DHT *dht, IP_Port ip_port, uint8_t *public_key, uint8_t *client_id, uint64_t ping_id) |
621 | { | 621 | { |
622 | /* Check if packet is going to be sent to ourself. */ | 622 | /* Check if packet is going to be sent to ourself. */ |
623 | if (id_equal(public_key, dht->c->self_public_key)) | 623 | if (id_equal(public_key, dht->c->self_public_key)) |
@@ -691,7 +691,9 @@ static int handle_getnodes(void *object, IP_Port source, uint8_t *packet, uint32 | |||
691 | memcpy(&ping_id, plain, sizeof(ping_id)); | 691 | memcpy(&ping_id, plain, sizeof(ping_id)); |
692 | sendnodes(dht, source, packet + 1, plain + sizeof(ping_id), ping_id); | 692 | sendnodes(dht, source, packet + 1, plain + sizeof(ping_id), ping_id); |
693 | #ifdef TOX_ENABLE_IPV6 | 693 | #ifdef TOX_ENABLE_IPV6 |
694 | sendnodes_ex(dht, source, packet + 1, plain + sizeof(ping_id), ping_id); | 694 | /* only try to send IPv6 nodes if the ipv6enabled flag was given */ |
695 | if (dht->c->lossless_udp->net->family == AF_INET6) | ||
696 | sendnodes_ipv6(dht, source, packet + 1, plain + sizeof(ping_id), ping_id); | ||
695 | #endif | 697 | #endif |
696 | 698 | ||
697 | //send_ping_request(dht, source, packet + 1); /* TODO: make this smarter? */ | 699 | //send_ping_request(dht, source, packet + 1); /* TODO: make this smarter? */ |
@@ -766,7 +768,7 @@ static int handle_sendnodes(void *object, IP_Port source, uint8_t *packet, uint3 | |||
766 | } | 768 | } |
767 | 769 | ||
768 | #ifdef TOX_ENABLE_IPV6 | 770 | #ifdef TOX_ENABLE_IPV6 |
769 | static int handle_sendnodes_ex(void *object, IP_Port source, uint8_t *packet, uint32_t length) | 771 | static int handle_sendnodes_ipv6(void *object, IP_Port source, uint8_t *packet, uint32_t length) |
770 | { | 772 | { |
771 | DHT *dht = object; | 773 | DHT *dht = object; |
772 | uint64_t ping_id; | 774 | uint64_t ping_id; |
@@ -979,7 +981,8 @@ void DHT_bootstrap(DHT *dht, IP_Port ip_port, uint8_t *public_key) | |||
979 | getnodes(dht, ip_port, public_key, dht->c->self_public_key); | 981 | getnodes(dht, ip_port, public_key, dht->c->self_public_key); |
980 | send_ping_request(dht->ping, dht->c, ip_port, public_key); | 982 | send_ping_request(dht->ping, dht->c, ip_port, public_key); |
981 | } | 983 | } |
982 | int DHT_bootstrap_ex(DHT *dht, const char *address, uint8_t ipv6enabled, uint16_t port, uint8_t *public_key) | 984 | int DHT_bootstrap_from_address(DHT *dht, const char *address, uint8_t ipv6enabled, |
985 | uint16_t port, uint8_t *public_key) | ||
983 | { | 986 | { |
984 | IP_Port ip_port; | 987 | IP_Port ip_port; |
985 | ip_init(&ip_port.ip, ipv6enabled); | 988 | ip_init(&ip_port.ip, ipv6enabled); |
@@ -1400,7 +1403,7 @@ DHT *new_DHT(Net_Crypto *c) | |||
1400 | networking_registerhandler(c->lossless_udp->net, NET_PACKET_GET_NODES, &handle_getnodes, temp); | 1403 | networking_registerhandler(c->lossless_udp->net, NET_PACKET_GET_NODES, &handle_getnodes, temp); |
1401 | networking_registerhandler(c->lossless_udp->net, NET_PACKET_SEND_NODES, &handle_sendnodes, temp); | 1404 | networking_registerhandler(c->lossless_udp->net, NET_PACKET_SEND_NODES, &handle_sendnodes, temp); |
1402 | #ifdef TOX_ENABLE_IPV6 | 1405 | #ifdef TOX_ENABLE_IPV6 |
1403 | networking_registerhandler(c->lossless_udp->net, NET_PACKET_SEND_NODES_EX, &handle_sendnodes_ex, temp); | 1406 | networking_registerhandler(c->lossless_udp->net, NET_PACKET_SEND_NODES_EX, &handle_sendnodes_ipv6, temp); |
1404 | #endif | 1407 | #endif |
1405 | init_cryptopackets(temp); | 1408 | init_cryptopackets(temp); |
1406 | cryptopacket_registerhandler(c, CRYPTO_PACKET_NAT_PING, &handle_NATping, temp); | 1409 | cryptopacket_registerhandler(c, CRYPTO_PACKET_NAT_PING, &handle_NATping, temp); |
diff --git a/toxcore/DHT.h b/toxcore/DHT.h index 90b76a2f..255074b0 100644 --- a/toxcore/DHT.h +++ b/toxcore/DHT.h | |||
@@ -136,7 +136,7 @@ int DHT_delfriend(DHT *dht, uint8_t *client_id); | |||
136 | * ip must be 4 bytes long. | 136 | * ip must be 4 bytes long. |
137 | * port must be 2 bytes long. | 137 | * port must be 2 bytes long. |
138 | * | 138 | * |
139 | * !!! Signature changed!!! | 139 | * !!! Signature changed !!! |
140 | * | 140 | * |
141 | * OLD: IP_Port DHT_getfriendip(DHT *dht, uint8_t *client_id); | 141 | * OLD: IP_Port DHT_getfriendip(DHT *dht, uint8_t *client_id); |
142 | * | 142 | * |
@@ -155,12 +155,26 @@ int DHT_getfriendip(DHT *dht, uint8_t *client_id, IP_Port *ip_port); | |||
155 | /* Run this function at least a couple times per second (It's the main loop). */ | 155 | /* Run this function at least a couple times per second (It's the main loop). */ |
156 | void do_DHT(DHT *dht); | 156 | void do_DHT(DHT *dht); |
157 | 157 | ||
158 | /* Use this function to bootstrap the client. | 158 | /* |
159 | * Sends a get nodes request to the given node with ip port and public_key. | 159 | * Use these two functions to bootstrap the client. |
160 | * DHT_bootstrap_ex() returns 1 if the address could be converted, 0 otherwise | 160 | */ |
161 | /* Sends a "get nodes" request to the given node with ip, port and public_key | ||
162 | * to setup connections | ||
161 | */ | 163 | */ |
162 | void DHT_bootstrap(DHT *dht, IP_Port ip_port, uint8_t *public_key); | 164 | void DHT_bootstrap(DHT *dht, IP_Port ip_port, uint8_t *public_key); |
163 | int DHT_bootstrap_ex(DHT *dht, const char *address, uint8_t ipv6enabled, uint16_t port, uint8_t *public_key); | 165 | /* Resolves address into an IP address. If successful, sends a "get nodes" |
166 | * request to the given node with ip, port and public_key to setup connections | ||
167 | * | ||
168 | * address can be a hostname or an IP address (IPv4 or IPv6). | ||
169 | * if ipv6enabled is 0 (zero), the resolving sticks STRICTLY to IPv4 addresses | ||
170 | * if ipv6enabled is not 0 (zero), the resolving looks for IPv6 addresses first, | ||
171 | * then IPv4 addresses. | ||
172 | * | ||
173 | * returns 1 if the address could be converted into an IP address | ||
174 | * returns 0 otherwise | ||
175 | */ | ||
176 | int DHT_bootstrap_from_address(DHT *dht, const char *address, uint8_t ipv6enabled, | ||
177 | uint16_t port, uint8_t *public_key); | ||
164 | 178 | ||
165 | /* Add nodes to the toping list. | 179 | /* Add nodes to the toping list. |
166 | * All nodes in this list are pinged every TIME_TOPING seconds | 180 | * All nodes in this list are pinged every TIME_TOPING seconds |
diff --git a/toxcore/LAN_discovery.c b/toxcore/LAN_discovery.c index 933c2402..b429ea6e 100644 --- a/toxcore/LAN_discovery.c +++ b/toxcore/LAN_discovery.c | |||
@@ -112,7 +112,9 @@ static IP broadcast_ip(sa_family_t family_socket, sa_family_t family_broadcast) | |||
112 | } | 112 | } |
113 | } | 113 | } |
114 | #else | 114 | #else |
115 | ip.uint32 = INADDR_BROADCAST; | 115 | if (family_socket == AF_INET) |
116 | if (family_broadcast == AF_INET) | ||
117 | ip.uint32 = INADDR_BROADCAST; | ||
116 | #endif | 118 | #endif |
117 | 119 | ||
118 | return ip; | 120 | return ip; |
@@ -193,23 +195,22 @@ int send_LANdiscovery(uint16_t port, Net_Crypto *c) | |||
193 | ip_port.port = port; | 195 | ip_port.port = port; |
194 | 196 | ||
195 | #ifdef TOX_ENABLE_IPV6 | 197 | #ifdef TOX_ENABLE_IPV6 |
198 | /* IPv6 multicast */ | ||
196 | if (c->lossless_udp->net->family == AF_INET6) { | 199 | if (c->lossless_udp->net->family == AF_INET6) { |
197 | ip_port.ip = broadcast_ip(c->lossless_udp->net->family, AF_INET6); | 200 | ip_port.ip = broadcast_ip(AF_INET6, AF_INET6); |
198 | if (ip_isset(&ip_port.ip)) | 201 | if (ip_isset(&ip_port.ip)) |
199 | if (sendpacket(c->lossless_udp->net, ip_port, data, 1 + crypto_box_PUBLICKEYBYTES) > 0) | 202 | if (sendpacket(c->lossless_udp->net, ip_port, data, 1 + crypto_box_PUBLICKEYBYTES) > 0) |
200 | res = 1; | 203 | res = 1; |
201 | } | 204 | } |
202 | 205 | ||
206 | /* IPv4 broadcast (has to be IPv4-in-IPv6 mapping if socket is AF_INET6 */ | ||
203 | ip_port.ip = broadcast_ip(c->lossless_udp->net->family, AF_INET); | 207 | ip_port.ip = broadcast_ip(c->lossless_udp->net->family, AF_INET); |
204 | if (ip_isset(&ip_port.ip)) | ||
205 | if (sendpacket(c->lossless_udp->net, ip_port, data, 1 + crypto_box_PUBLICKEYBYTES)) | ||
206 | res = 1; | ||
207 | #else | 208 | #else |
208 | ip_port.ip = broadcast_ip(c->lossless_udp->net->family, AF_INET); | 209 | ip_port.ip = broadcast_ip(AF_INET, AF_INET); |
210 | #endif | ||
209 | if (ip_isset(&ip_port.ip)) | 211 | if (ip_isset(&ip_port.ip)) |
210 | if (sendpacket(c->lossless_udp->net, ip_port, data, 1 + crypto_box_PUBLICKEYBYTES)) | 212 | if (sendpacket(c->lossless_udp->net, ip_port, data, 1 + crypto_box_PUBLICKEYBYTES)) |
211 | res = 1; | 213 | res = 1; |
212 | #endif | ||
213 | 214 | ||
214 | return res; | 215 | return res; |
215 | } | 216 | } |
diff --git a/toxcore/network.c b/toxcore/network.c index de69bb3a..b40f7d56 100644 --- a/toxcore/network.c +++ b/toxcore/network.c | |||
@@ -312,7 +312,7 @@ Networking_Core *new_networking(IP ip, uint16_t port) | |||
312 | return -1; | 312 | return -1; |
313 | */ | 313 | */ |
314 | 314 | ||
315 | /* Enable broadcast on socket? */ | 315 | /* Enable broadcast on socket */ |
316 | int broadcast = 1; | 316 | int broadcast = 1; |
317 | setsockopt(temp->sock, SOL_SOCKET, SO_BROADCAST, (char *)&broadcast, sizeof(broadcast)); | 317 | setsockopt(temp->sock, SOL_SOCKET, SO_BROADCAST, (char *)&broadcast, sizeof(broadcast)); |
318 | 318 | ||
@@ -402,6 +402,18 @@ Networking_Core *new_networking(IP ip, uint16_t port) | |||
402 | /* a hanging program or a different user might block the standard port; | 402 | /* a hanging program or a different user might block the standard port; |
403 | * as long as it isn't a parameter coming from the commandline, | 403 | * as long as it isn't a parameter coming from the commandline, |
404 | * try a few ports after it, to see if we can find a "free" one | 404 | * try a few ports after it, to see if we can find a "free" one |
405 | * | ||
406 | * if we go on without binding, the first sendto() automatically binds to | ||
407 | * a free port chosen by the system (i.e. anything from 1024 to 65535) | ||
408 | * | ||
409 | * returning NULL after bind fails has both advantages and disadvantages: | ||
410 | * advantage: | ||
411 | * we can rely on getting the port in the range 33445..33450, which | ||
412 | * enables us to tell joe user to open their firewall to a small range | ||
413 | * | ||
414 | * disadvantage: | ||
415 | * some clients might not test return of tox_new(), blindly assuming that | ||
416 | * it worked ok (which it did previously without a successful bind) | ||
405 | */ | 417 | */ |
406 | int tries, res; | 418 | int tries, res; |
407 | for(tries = 0; tries < 9; tries++) | 419 | for(tries = 0; tries < 9; tries++) |
diff --git a/toxcore/tox.c b/toxcore/tox.c index 5e3893ec..31ae9c0f 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -374,11 +374,11 @@ void tox_bootstrap(void *tox, IP_Port ip_port, uint8_t *public_key) | |||
374 | Messenger *m = tox; | 374 | Messenger *m = tox; |
375 | DHT_bootstrap(m->dht, ip_port, public_key); | 375 | DHT_bootstrap(m->dht, ip_port, public_key); |
376 | } | 376 | } |
377 | int tox_bootstrap_ex(void *tox, const char *address, uint8_t ipv6enabled, | 377 | int tox_bootstrap_from_address(void *tox, const char *address, |
378 | uint16_t port, uint8_t *public_key) | 378 | uint8_t ipv6enabled, uint16_t port, uint8_t *public_key) |
379 | { | 379 | { |
380 | Messenger *m = tox; | 380 | Messenger *m = tox; |
381 | return DHT_bootstrap_ex(m->dht, address, ipv6enabled, port, public_key); | 381 | return DHT_bootstrap_from_address(m->dht, address, ipv6enabled, port, public_key); |
382 | }; | 382 | }; |
383 | 383 | ||
384 | /* return 0 if we are not connected to the DHT. | 384 | /* return 0 if we are not connected to the DHT. |
diff --git a/toxcore/tox.h b/toxcore/tox.h index cf5d6b2a..b331479e 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h | |||
@@ -338,12 +338,25 @@ void tox_callback_read_receipt(Tox *tox, void (*function)(Tox *tox, int, uint32_ | |||
338 | */ | 338 | */ |
339 | void tox_callback_connectionstatus(Tox *tox, void (*function)(Tox *tox, int, uint8_t, void *), void *userdata); | 339 | void tox_callback_connectionstatus(Tox *tox, void (*function)(Tox *tox, int, uint8_t, void *), void *userdata); |
340 | 340 | ||
341 | /* Use this function to bootstrap the client. | 341 | /* |
342 | * Sends a get nodes request to the given node with ip port and public_key. | 342 | * Use these two functions to bootstrap the client. |
343 | * tox_bootstrap_ex() returns 1 if the address could be converted, 0 otherwise | 343 | */ |
344 | /* Sends a "get nodes" request to the given node with ip, port and public_key | ||
345 | * to setup connections | ||
344 | */ | 346 | */ |
345 | void tox_bootstrap(Tox *tox, tox_IP_Port ip_port, uint8_t *public_key); | 347 | void tox_bootstrap(Tox *tox, tox_IP_Port ip_port, uint8_t *public_key); |
346 | int tox_bootstrap_ex(Tox *tox, const char *address, uint8_t ipv6enabled, | 348 | /* Resolves address into an IP address. If successful, sends a "get nodes" |
349 | * request to the given node with ip, port and public_key to setup connections | ||
350 | * | ||
351 | * address can be a hostname or an IP address (IPv4 or IPv6). | ||
352 | * if ipv6enabled is 0 (zero), the resolving sticks STRICTLY to IPv4 addresses | ||
353 | * if ipv6enabled is not 0 (zero), the resolving looks for IPv6 addresses first, | ||
354 | * then IPv4 addresses. | ||
355 | * | ||
356 | * returns 1 if the address could be converted into an IP address | ||
357 | * returns 0 otherwise | ||
358 | */ | ||
359 | int tox_bootstrap_from_address(Tox *tox, const char *address, uint8_t ipv6enabled, | ||
347 | uint16_t port, uint8_t *public_key); | 360 | uint16_t port, uint8_t *public_key); |
348 | 361 | ||
349 | /* return 0 if we are not connected to the DHT. | 362 | /* return 0 if we are not connected to the DHT. |
@@ -351,12 +364,27 @@ int tox_bootstrap_ex(Tox *tox, const char *address, uint8_t ipv6enabled, | |||
351 | */ | 364 | */ |
352 | int tox_isconnected(Tox *tox); | 365 | int tox_isconnected(Tox *tox); |
353 | 366 | ||
354 | /* Run this at startup. | 367 | /* |
368 | * Run one of the following two functions at startup. | ||
369 | */ | ||
370 | /* Initializes a tox structure | ||
371 | * Defaults to using ipv4 connections only. | ||
355 | * | 372 | * |
356 | * return allocated instance of tox on success. | 373 | * return allocated instance of tox on success. |
357 | * return 0 if there are problems. | 374 | * return 0 if there are problems. |
358 | */ | 375 | */ |
359 | Tox *tox_new(void); | 376 | Tox *tox_new(void); |
377 | |||
378 | /* Initializes a tox structure | ||
379 | * The type of communication socket depends on ipv6enabled: | ||
380 | * If set to 0 (zero), creates an IPv4 socket which subsequently only allows | ||
381 | * IPv4 communication | ||
382 | * If set to anything else, creates an IPv6 socket which allows both IPv4 AND | ||
383 | * IPv6 communication | ||
384 | * | ||
385 | * return allocated instance of tox on success. | ||
386 | * return 0 if there are problems. | ||
387 | */ | ||
360 | Tox *tox_new_ex(uint8_t ipv6enabled); | 388 | Tox *tox_new_ex(uint8_t ipv6enabled); |
361 | 389 | ||
362 | /* Run this before closing shop. | 390 | /* Run this before closing shop. |
diff --git a/toxcore/util.c b/toxcore/util.c index 19d464d4..e751e9e4 100644 --- a/toxcore/util.c +++ b/toxcore/util.c | |||
@@ -51,7 +51,7 @@ void loginit(uint16_t port) | |||
51 | if (logfile) | 51 | if (logfile) |
52 | fclose(logfile); | 52 | fclose(logfile); |
53 | 53 | ||
54 | sprintf(logbuffer, "%u-%u.log", ntohs(port), now); | 54 | sprintf(logbuffer, "%u-%u.log", ntohs(port), now()); |
55 | logfile = fopen(logbuffer, "w"); | 55 | logfile = fopen(logbuffer, "w"); |
56 | }; | 56 | }; |
57 | void loglog(char *text) | 57 | void loglog(char *text) |