Modified tox_bootstrap_from_address() function.

PORT IS NO LONGER PASSED IN NETWORK BYTE ORDER.

Removed useless ipv6enabled parameter.
This commit is contained in:
irungentoo 2014-08-14 19:01:21 -04:00
parent ef78169842
commit 7557b92fc9
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
4 changed files with 10 additions and 15 deletions

View File

@ -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]);
@ -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);
}
}
}

View File

@ -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) {

View File

@ -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.

View File

@ -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.