diff options
Diffstat (limited to 'toxcore/DHT.c')
-rw-r--r-- | toxcore/DHT.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c index e748da7c..29e6baa3 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c | |||
@@ -1422,12 +1422,20 @@ static uint8_t do_ping_and_sendnode_requests(DHT *dht, uint64_t *lastgetnode, co | |||
1422 | if (rand_node >= num_nodes) { | 1422 | if (rand_node >= num_nodes) { |
1423 | rand_node = rand_node % num_nodes; | 1423 | rand_node = rand_node % num_nodes; |
1424 | 1424 | ||
1425 | if ((num_nodes - 1) != rand_node) { | ||
1426 | rand_node += rand() % (num_nodes - (rand_node + 1)); | ||
1427 | } | ||
1428 | |||
1425 | if (memcmp(client_list[rand_node]->public_key, public_key, crypto_box_PUBLICKEYBYTES) != 0) { | 1429 | if (memcmp(client_list[rand_node]->public_key, public_key, crypto_box_PUBLICKEYBYTES) != 0) { |
1426 | uint8_t get_pk[crypto_box_PUBLICKEYBYTES]; | 1430 | uint8_t get_pk[crypto_box_PUBLICKEYBYTES]; |
1427 | find_midpoint(get_pk, client_list[rand_node]->public_key, public_key); | 1431 | find_midpoint(get_pk, client_list[rand_node]->public_key, public_key); |
1428 | getnodes(dht, assoc_list[rand_node]->ip_port, client_list[rand_node]->public_key, get_pk, NULL); | 1432 | getnodes(dht, assoc_list[rand_node]->ip_port, client_list[rand_node]->public_key, get_pk, NULL); |
1429 | } | 1433 | } |
1430 | } else { | 1434 | } else { |
1435 | if ((num_nodes - 1) != rand_node) { | ||
1436 | rand_node += rand() % (num_nodes - (rand_node + 1)); | ||
1437 | } | ||
1438 | |||
1431 | getnodes(dht, assoc_list[rand_node]->ip_port, client_list[rand_node]->public_key, public_key, NULL); | 1439 | getnodes(dht, assoc_list[rand_node]->ip_port, client_list[rand_node]->public_key, public_key, NULL); |
1432 | } | 1440 | } |
1433 | 1441 | ||