Skip to content

Commit

Permalink
Modified tox_bootstrap_from_address() function.
Browse files Browse the repository at this point in the history
PORT IS NO LONGER PASSED IN NETWORK BYTE ORDER.

Removed useless ipv6enabled parameter.
  • Loading branch information
irungentoo committed Aug 14, 2014
1 parent ef78169 commit 7557b92
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
6 changes: 3 additions & 3 deletions testing/nTox.c
Original file line number Diff line number Diff line change
Expand Up @@ -1255,9 +1255,9 @@ int main(int argc, char *argv[])
new_lines(idstring);
strcpy(input_line, "");

uint16_t port = htons(atoi(argv[argvoffset + 2]));
uint16_t port = atoi(argv[argvoffset + 2]);
unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]);
int res = tox_bootstrap_from_address(m, argv[argvoffset + 1], ipv6enabled, port, binary_string);
int res = tox_bootstrap_from_address(m, argv[argvoffset + 1], port, binary_string);

if (!res) {
printf("Failed to convert \"%s\" into an IP address. Exiting...\n", argv[argvoffset + 1]);
Expand Down Expand Up @@ -1290,7 +1290,7 @@ int main(int argc, char *argv[])

if (timestamp0 + 10 < timestamp1) {
timestamp0 = timestamp1;
tox_bootstrap_from_address(m, argv[argvoffset + 1], ipv6enabled, port, binary_string);
tox_bootstrap_from_address(m, argv[argvoffset + 1], port, binary_string);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions testing/tox_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ int main(int argc, char *argv[])
tox_callback_file_send_request(tox, file_request_accept, NULL);
tox_callback_connection_status(tox, print_online, NULL);

uint16_t port = htons(atoi(argv[argvoffset + 2]));
uint16_t port = atoi(argv[argvoffset + 2]);
unsigned char *binary_string = hex_string_to_bin(argv[argvoffset + 3]);
int res = tox_bootstrap_from_address(tox, argv[argvoffset + 1], ipv6enabled, port, binary_string);
int res = tox_bootstrap_from_address(tox, argv[argvoffset + 1], port, binary_string);
free(binary_string);

if (!res) {
Expand Down
7 changes: 3 additions & 4 deletions toxcore/tox.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,12 +782,11 @@ static int tox_add_tcp_relay(Tox *tox, const char *address, uint8_t ipv6enabled,
}
}

int tox_bootstrap_from_address(Tox *tox, const char *address,
uint8_t ipv6enabled, uint16_t port, const uint8_t *public_key)
int tox_bootstrap_from_address(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key)
{
Messenger *m = tox;
tox_add_tcp_relay(tox, address, ipv6enabled, port, public_key);
return DHT_bootstrap_from_address(m->dht, address, ipv6enabled, port, public_key);
tox_add_tcp_relay(tox, address, m->options.ipv6enabled, htons(port), public_key);
return DHT_bootstrap_from_address(m->dht, address, m->options.ipv6enabled, htons(port), public_key);
}

/* return 0 if we are not connected to the DHT.
Expand Down
8 changes: 2 additions & 6 deletions toxcore/tox.h
Original file line number Diff line number Diff line change
Expand Up @@ -603,19 +603,15 @@ uint64_t tox_file_data_remaining(const Tox *tox, int32_t friendnumber, uint8_t f
*/

/* Resolves address into an IP address. If successful, sends a "get nodes"
* request to the given node with ip, port (in network byte order, HINT: use htons())
* request to the given node with ip, port (in host byte order).
* and public_key to setup connections
*
* address can be a hostname or an IP address (IPv4 or IPv6).
* if ipv6enabled is 0 (zero), the resolving sticks STRICTLY to IPv4 addresses
* if ipv6enabled is not 0 (zero), the resolving looks for IPv6 addresses first,
* then IPv4 addresses.
*
* returns 1 if the address could be converted into an IP address
* returns 0 otherwise
*/
int tox_bootstrap_from_address(Tox *tox, const char *address, uint8_t ipv6enabled,
uint16_t port, const uint8_t *public_key);
int tox_bootstrap_from_address(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key);

/* return 0 if we are not connected to the DHT.
* return 1 if we are.
Expand Down

0 comments on commit 7557b92

Please sign in to comment.