diff options
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/onion_client.c | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c index 337bc296..7cba27a9 100644 --- a/toxcore/onion_client.c +++ b/toxcore/onion_client.c | |||
@@ -766,24 +766,26 @@ static void do_friend(Onion_Client *onion_c, uint16_t friendnum) | |||
766 | } | 766 | } |
767 | } | 767 | } |
768 | 768 | ||
769 | if (count < MAX_ONION_CLIENTS / 2) { | 769 | if (count != MAX_ONION_CLIENTS) { |
770 | Node_format nodes_list[MAX_SENT_NODES]; | 770 | if (count < rand() % MAX_ONION_CLIENTS) { |
771 | uint32_t num_nodes = get_close_nodes(onion_c->dht, onion_c->friends_list[friendnum].real_client_id, nodes_list, | 771 | Node_format nodes_list[MAX_SENT_NODES]; |
772 | rand() % 2 ? AF_INET : AF_INET6, 1, 0); | 772 | uint32_t num_nodes = get_close_nodes(onion_c->dht, onion_c->friends_list[friendnum].real_client_id, nodes_list, |
773 | 773 | rand() % 2 ? AF_INET : AF_INET6, 1, 0); | |
774 | for (i = 0; i < num_nodes; ++i) | 774 | |
775 | client_send_announce_request(onion_c, friendnum + 1, nodes_list[i].ip_port, nodes_list[i].client_id, 0); | 775 | for (i = 0; i < num_nodes; ++i) |
776 | } | 776 | client_send_announce_request(onion_c, friendnum + 1, nodes_list[i].ip_port, nodes_list[i].client_id, 0); |
777 | } | ||
777 | 778 | ||
778 | 779 | ||
779 | /* send packets to friend telling them our fake DHT id. */ | 780 | /* send packets to friend telling them our fake DHT id. */ |
780 | if (is_timeout(onion_c->friends_list[friendnum].last_fakeid_onion_sent, ONION_FAKEID_INTERVAL)) | 781 | if (is_timeout(onion_c->friends_list[friendnum].last_fakeid_onion_sent, ONION_FAKEID_INTERVAL)) |
781 | if (send_fakeid_announce(onion_c, friendnum, 0) >= 1) | 782 | if (send_fakeid_announce(onion_c, friendnum, 0) >= 1) |
782 | onion_c->friends_list[friendnum].last_fakeid_onion_sent = unix_time(); | 783 | onion_c->friends_list[friendnum].last_fakeid_onion_sent = unix_time(); |
783 | 784 | ||
784 | if (is_timeout(onion_c->friends_list[friendnum].last_fakeid_dht_sent, DHT_FAKEID_INTERVAL)) | 785 | if (is_timeout(onion_c->friends_list[friendnum].last_fakeid_dht_sent, DHT_FAKEID_INTERVAL)) |
785 | if (send_fakeid_announce(onion_c, friendnum, 1) >= 1) | 786 | if (send_fakeid_announce(onion_c, friendnum, 1) >= 1) |
786 | onion_c->friends_list[friendnum].last_fakeid_dht_sent = unix_time(); | 787 | onion_c->friends_list[friendnum].last_fakeid_dht_sent = unix_time(); |
788 | } | ||
787 | } | 789 | } |
788 | } | 790 | } |
789 | /* Function to call when onion data packet with contents beginning with byte is received. */ | 791 | /* Function to call when onion data packet with contents beginning with byte is received. */ |
@@ -820,13 +822,15 @@ static void do_announce(Onion_Client *onion_c) | |||
820 | } | 822 | } |
821 | } | 823 | } |
822 | 824 | ||
823 | if (count < MAX_ONION_CLIENTS / 2) { | 825 | if (count != MAX_ONION_CLIENTS) { |
824 | Node_format nodes_list[MAX_SENT_NODES]; | 826 | if (count < rand() % MAX_ONION_CLIENTS) { |
825 | uint32_t num_nodes = get_close_nodes(onion_c->dht, onion_c->dht->c->self_public_key, nodes_list, | 827 | Node_format nodes_list[MAX_SENT_NODES]; |
826 | rand() % 2 ? AF_INET : AF_INET6, 1, 0); | 828 | uint32_t num_nodes = get_close_nodes(onion_c->dht, onion_c->dht->c->self_public_key, nodes_list, |
829 | rand() % 2 ? AF_INET : AF_INET6, 1, 0); | ||
827 | 830 | ||
828 | for (i = 0; i < num_nodes; ++i) | 831 | for (i = 0; i < num_nodes; ++i) |
829 | client_send_announce_request(onion_c, 0, nodes_list[i].ip_port, nodes_list[i].client_id, 0); | 832 | client_send_announce_request(onion_c, 0, nodes_list[i].ip_port, nodes_list[i].client_id, 0); |
833 | } | ||
830 | } | 834 | } |
831 | } | 835 | } |
832 | 836 | ||