diff options
Diffstat (limited to 'toxcore/DHT.c')
-rw-r--r-- | toxcore/DHT.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c index 3de7b6ae..a5f0c1ab 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c | |||
@@ -982,11 +982,28 @@ void DHT_bootstrap(DHT *dht, IP_Port ip_port, uint8_t *public_key) | |||
982 | int DHT_bootstrap_from_address(DHT *dht, const char *address, uint8_t ipv6enabled, | 982 | int DHT_bootstrap_from_address(DHT *dht, const char *address, uint8_t ipv6enabled, |
983 | uint16_t port, uint8_t *public_key) | 983 | uint16_t port, uint8_t *public_key) |
984 | { | 984 | { |
985 | IP_Port ip_port; | 985 | IP_Port ip_port_v64, ip_port_v4; |
986 | ip_init(&ip_port.ip, ipv6enabled); | 986 | IP *ip_extra = NULL; |
987 | if (addr_resolve_or_parse_ip(address, &ip_port.ip)) { | 987 | #ifdef TOX_ENABLE_IPV6 |
988 | ip_port.port = port; | 988 | ip_init(&ip_port_v64.ip, ipv6enabled); |
989 | DHT_bootstrap(dht, ip_port, public_key); | 989 | if (ipv6enabled) { |
990 | ip_port_v64.ip.family = AF_UNSPEC; | ||
991 | ip_reset(&ip_port_v4.ip); | ||
992 | ip_extra = &ip_port_v4.ip; | ||
993 | } | ||
994 | #else | ||
995 | ip_init(&ip_port_v64.ip, 0); | ||
996 | #endif | ||
997 | |||
998 | if (addr_resolve_or_parse_ip(address, &ip_port_v64.ip, ip_extra)) { | ||
999 | ip_port_v64.port = port; | ||
1000 | DHT_bootstrap(dht, ip_port_v64, public_key); | ||
1001 | #ifdef TOX_ENABLE_IPV6 | ||
1002 | if ((ip_extra != NULL) && ip_isset(ip_extra)) { | ||
1003 | ip_port_v4.port = port; | ||
1004 | DHT_bootstrap(dht, ip_port_v4, public_key); | ||
1005 | } | ||
1006 | #endif | ||
990 | return 1; | 1007 | return 1; |
991 | } | 1008 | } |
992 | else | 1009 | else |