diff options
Diffstat (limited to 'toxcore/tox.c')
-rw-r--r-- | toxcore/tox.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/toxcore/tox.c b/toxcore/tox.c index ca87bbe1..d9d88105 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -729,17 +729,20 @@ uint64_t tox_file_data_remaining(const Tox *tox, int32_t friendnumber, uint8_t f | |||
729 | 729 | ||
730 | /***************END OF FILE SENDING FUNCTIONS******************/ | 730 | /***************END OF FILE SENDING FUNCTIONS******************/ |
731 | 731 | ||
732 | /* TODO: expose this properly. */ | 732 | /* Like tox_bootstrap_from_address but for TCP relays only. |
733 | static int tox_add_tcp_relay(Tox *tox, const char *address, uint8_t ipv6enabled, uint16_t port, | 733 | * |
734 | const uint8_t *public_key) | 734 | * return 0 on failure. |
735 | * return 1 on success. | ||
736 | */ | ||
737 | int tox_add_tcp_relay(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key) | ||
735 | { | 738 | { |
736 | Messenger *m = tox; | 739 | Messenger *m = tox; |
737 | IP_Port ip_port_v64; | 740 | IP_Port ip_port_v64; |
738 | IP *ip_extra = NULL; | 741 | IP *ip_extra = NULL; |
739 | IP_Port ip_port_v4; | 742 | IP_Port ip_port_v4; |
740 | ip_init(&ip_port_v64.ip, ipv6enabled); | 743 | ip_init(&ip_port_v64.ip, m->options.ipv6enabled); |
741 | 744 | ||
742 | if (ipv6enabled) { | 745 | if (m->options.ipv6enabled) { |
743 | /* setup for getting BOTH: an IPv6 AND an IPv4 address */ | 746 | /* setup for getting BOTH: an IPv6 AND an IPv4 address */ |
744 | ip_port_v64.ip.family = AF_UNSPEC; | 747 | ip_port_v64.ip.family = AF_UNSPEC; |
745 | ip_reset(&ip_port_v4.ip); | 748 | ip_reset(&ip_port_v4.ip); |
@@ -747,7 +750,7 @@ static int tox_add_tcp_relay(Tox *tox, const char *address, uint8_t ipv6enabled, | |||
747 | } | 750 | } |
748 | 751 | ||
749 | if (addr_resolve_or_parse_ip(address, &ip_port_v64.ip, ip_extra)) { | 752 | if (addr_resolve_or_parse_ip(address, &ip_port_v64.ip, ip_extra)) { |
750 | ip_port_v64.port = port; | 753 | ip_port_v64.port = htons(port); |
751 | add_tcp_relay(m->net_crypto, ip_port_v64, public_key); | 754 | add_tcp_relay(m->net_crypto, ip_port_v64, public_key); |
752 | onion_add_path_node(m->onion_c, ip_port_v64, public_key); //TODO: move this | 755 | onion_add_path_node(m->onion_c, ip_port_v64, public_key); //TODO: move this |
753 | return 1; | 756 | return 1; |
@@ -759,7 +762,7 @@ static int tox_add_tcp_relay(Tox *tox, const char *address, uint8_t ipv6enabled, | |||
759 | int tox_bootstrap_from_address(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key) | 762 | int tox_bootstrap_from_address(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key) |
760 | { | 763 | { |
761 | Messenger *m = tox; | 764 | Messenger *m = tox; |
762 | tox_add_tcp_relay(tox, address, m->options.ipv6enabled, htons(port), public_key); | 765 | tox_add_tcp_relay(tox, address, port, public_key); |
763 | return DHT_bootstrap_from_address(m->dht, address, m->options.ipv6enabled, htons(port), public_key); | 766 | return DHT_bootstrap_from_address(m->dht, address, m->options.ipv6enabled, htons(port), public_key); |
764 | } | 767 | } |
765 | 768 | ||