summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2014-08-14 19:01:21 -0400
committerirungentoo <irungentoo@gmail.com>2014-08-14 19:01:21 -0400
commit7557b92fc9699e0c762e627f97b4d997506ddedf (patch)
tree7134ff512c5aa2325dc40ca887767397a7ba9242
parentef78169842514d6f8507caebb7f791b9227812bf (diff)
Modified tox_bootstrap_from_address() function.
PORT IS NO LONGER PASSED IN NETWORK BYTE ORDER. Removed useless ipv6enabled parameter.
-rw-r--r--testing/nTox.c6
-rw-r--r--testing/tox_sync.c4
-rw-r--r--toxcore/tox.c7
-rw-r--r--toxcore/tox.h8
4 files changed, 10 insertions, 15 deletions
diff --git a/testing/nTox.c b/testing/nTox.c
index 53cbbb5d..edda43b1 100644
--- a/testing/nTox.c
+++ b/testing/nTox.c
@@ -1255,9 +1255,9 @@ int main(int argc, char *argv[])
1255 new_lines(idstring); 1255 new_lines(idstring);
1256 strcpy(input_line, ""); 1256 strcpy(input_line, "");
1257 1257
1258 uint16_t port = htons(atoi(argv[argvoffset + 2])); 1258 uint16_t port = atoi(argv[argvoffset + 2]);
1259 unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]); 1259 unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]);
1260 int res = tox_bootstrap_from_address(m, argv[argvoffset + 1], ipv6enabled, port, binary_string); 1260 int res = tox_bootstrap_from_address(m, argv[argvoffset + 1], port, binary_string);
1261 1261
1262 if (!res) { 1262 if (!res) {
1263 printf("Failed to convert \"%s\" into an IP address. Exiting...\n", argv[argvoffset + 1]); 1263 printf("Failed to convert \"%s\" into an IP address. Exiting...\n", argv[argvoffset + 1]);
@@ -1290,7 +1290,7 @@ int main(int argc, char *argv[])
1290 1290
1291 if (timestamp0 + 10 < timestamp1) { 1291 if (timestamp0 + 10 < timestamp1) {
1292 timestamp0 = timestamp1; 1292 timestamp0 = timestamp1;
1293 tox_bootstrap_from_address(m, argv[argvoffset + 1], ipv6enabled, port, binary_string); 1293 tox_bootstrap_from_address(m, argv[argvoffset + 1], port, binary_string);
1294 } 1294 }
1295 } 1295 }
1296 } 1296 }
diff --git a/testing/tox_sync.c b/testing/tox_sync.c
index 206e613f..8b64b6ca 100644
--- a/testing/tox_sync.c
+++ b/testing/tox_sync.c
@@ -220,9 +220,9 @@ int main(int argc, char *argv[])
220 tox_callback_file_send_request(tox, file_request_accept, NULL); 220 tox_callback_file_send_request(tox, file_request_accept, NULL);
221 tox_callback_connection_status(tox, print_online, NULL); 221 tox_callback_connection_status(tox, print_online, NULL);
222 222
223 uint16_t port = htons(atoi(argv[argvoffset + 2])); 223 uint16_t port = atoi(argv[argvoffset + 2]);
224 unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]); 224 unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]);
225 int res = tox_bootstrap_from_address(tox, argv[argvoffset + 1], ipv6enabled, port, binary_string); 225 int res = tox_bootstrap_from_address(tox, argv[argvoffset + 1], port, binary_string);
226 free(binary_string); 226 free(binary_string);
227 227
228 if (!res) { 228 if (!res) {
diff --git a/toxcore/tox.c b/toxcore/tox.c
index 4b9cff8e..a43a9554 100644
--- a/toxcore/tox.c
+++ b/toxcore/tox.c
@@ -782,12 +782,11 @@ static int tox_add_tcp_relay(Tox *tox, const char *address, uint8_t ipv6enabled,
782 } 782 }
783} 783}
784 784
785int tox_bootstrap_from_address(Tox *tox, const char *address, 785int tox_bootstrap_from_address(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key)
786 uint8_t ipv6enabled, uint16_t port, const uint8_t *public_key)
787{ 786{
788 Messenger *m = tox; 787 Messenger *m = tox;
789 tox_add_tcp_relay(tox, address, ipv6enabled, port, public_key); 788 tox_add_tcp_relay(tox, address, m->options.ipv6enabled, htons(port), public_key);
790 return DHT_bootstrap_from_address(m->dht, address, ipv6enabled, port, public_key); 789 return DHT_bootstrap_from_address(m->dht, address, m->options.ipv6enabled, htons(port), public_key);
791} 790}
792 791
793/* return 0 if we are not connected to the DHT. 792/* return 0 if we are not connected to the DHT.
diff --git a/toxcore/tox.h b/toxcore/tox.h
index 6cad6b10..c9a6bc70 100644
--- a/toxcore/tox.h
+++ b/toxcore/tox.h
@@ -603,19 +603,15 @@ uint64_t tox_file_data_remaining(const Tox *tox, int32_t friendnumber, uint8_t f
603 */ 603 */
604 604
605/* Resolves address into an IP address. If successful, sends a "get nodes" 605/* Resolves address into an IP address. If successful, sends a "get nodes"
606 * request to the given node with ip, port (in network byte order, HINT: use htons()) 606 * request to the given node with ip, port (in host byte order).
607 * and public_key to setup connections 607 * and public_key to setup connections
608 * 608 *
609 * address can be a hostname or an IP address (IPv4 or IPv6). 609 * address can be a hostname or an IP address (IPv4 or IPv6).
610 * if ipv6enabled is 0 (zero), the resolving sticks STRICTLY to IPv4 addresses
611 * if ipv6enabled is not 0 (zero), the resolving looks for IPv6 addresses first,
612 * then IPv4 addresses.
613 * 610 *
614 * returns 1 if the address could be converted into an IP address 611 * returns 1 if the address could be converted into an IP address
615 * returns 0 otherwise 612 * returns 0 otherwise
616 */ 613 */
617int tox_bootstrap_from_address(Tox *tox, const char *address, uint8_t ipv6enabled, 614int tox_bootstrap_from_address(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key);
618 uint16_t port, const uint8_t *public_key);
619 615
620/* return 0 if we are not connected to the DHT. 616/* return 0 if we are not connected to the DHT.
621 * return 1 if we are. 617 * return 1 if we are.