diff options
Diffstat (limited to 'toxcore/tox.c')
-rw-r--r-- | toxcore/tox.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/toxcore/tox.c b/toxcore/tox.c index d86f1a17..083582bb 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -739,12 +739,38 @@ uint64_t tox_file_data_remaining(Tox *tox, int32_t friendnumber, uint8_t filenum | |||
739 | 739 | ||
740 | /***************END OF FILE SENDING FUNCTIONS******************/ | 740 | /***************END OF FILE SENDING FUNCTIONS******************/ |
741 | 741 | ||
742 | /* TODO: expose this properly. */ | ||
743 | static int tox_add_tcp_relay(Tox *tox, const char *address, uint8_t ipv6enabled, uint16_t port, uint8_t *public_key) | ||
744 | { | ||
745 | Messenger *m = tox; | ||
746 | IP_Port ip_port_v64; | ||
747 | IP *ip_extra = NULL; | ||
748 | IP_Port ip_port_v4; | ||
749 | ip_init(&ip_port_v64.ip, ipv6enabled); | ||
750 | |||
751 | if (ipv6enabled) { | ||
752 | /* setup for getting BOTH: an IPv6 AND an IPv4 address */ | ||
753 | ip_port_v64.ip.family = AF_UNSPEC; | ||
754 | ip_reset(&ip_port_v4.ip); | ||
755 | ip_extra = &ip_port_v4.ip; | ||
756 | } | ||
757 | |||
758 | if (addr_resolve_or_parse_ip(address, &ip_port_v64.ip, ip_extra)) { | ||
759 | ip_port_v64.port = port; | ||
760 | add_tcp_relay(m->net_crypto, ip_port_v64, public_key); | ||
761 | return 1; | ||
762 | } else { | ||
763 | return 0; | ||
764 | } | ||
765 | } | ||
766 | |||
742 | int tox_bootstrap_from_address(Tox *tox, const char *address, | 767 | int tox_bootstrap_from_address(Tox *tox, const char *address, |
743 | uint8_t ipv6enabled, uint16_t port, uint8_t *public_key) | 768 | uint8_t ipv6enabled, uint16_t port, uint8_t *public_key) |
744 | { | 769 | { |
745 | Messenger *m = tox; | 770 | Messenger *m = tox; |
771 | tox_add_tcp_relay(tox, address, ipv6enabled, port, public_key); | ||
746 | return DHT_bootstrap_from_address(m->dht, address, ipv6enabled, port, public_key); | 772 | return DHT_bootstrap_from_address(m->dht, address, ipv6enabled, port, public_key); |
747 | }; | 773 | } |
748 | 774 | ||
749 | /* return 0 if we are not connected to the DHT. | 775 | /* return 0 if we are not connected to the DHT. |
750 | * return 1 if we are. | 776 | * return 1 if we are. |