mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Improved onion connection by a bit.
This commit is contained in:
parent
51717825c1
commit
a377c7fbf4
|
@ -766,7 +766,8 @@ static void do_friend(Onion_Client *onion_c, uint16_t friendnum)
|
|||
}
|
||||
}
|
||||
|
||||
if (count < MAX_ONION_CLIENTS / 2) {
|
||||
if (count != MAX_ONION_CLIENTS) {
|
||||
if (count < rand() % MAX_ONION_CLIENTS) {
|
||||
Node_format nodes_list[MAX_SENT_NODES];
|
||||
uint32_t num_nodes = get_close_nodes(onion_c->dht, onion_c->friends_list[friendnum].real_client_id, nodes_list,
|
||||
rand() % 2 ? AF_INET : AF_INET6, 1, 0);
|
||||
|
@ -786,6 +787,7 @@ static void do_friend(Onion_Client *onion_c, uint16_t friendnum)
|
|||
onion_c->friends_list[friendnum].last_fakeid_dht_sent = unix_time();
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Function to call when onion data packet with contents beginning with byte is received. */
|
||||
void oniondata_registerhandler(Onion_Client *onion_c, uint8_t byte, oniondata_handler_callback cb, void *object)
|
||||
{
|
||||
|
@ -820,7 +822,8 @@ static void do_announce(Onion_Client *onion_c)
|
|||
}
|
||||
}
|
||||
|
||||
if (count < MAX_ONION_CLIENTS / 2) {
|
||||
if (count != MAX_ONION_CLIENTS) {
|
||||
if (count < rand() % MAX_ONION_CLIENTS) {
|
||||
Node_format nodes_list[MAX_SENT_NODES];
|
||||
uint32_t num_nodes = get_close_nodes(onion_c->dht, onion_c->dht->c->self_public_key, nodes_list,
|
||||
rand() % 2 ? AF_INET : AF_INET6, 1, 0);
|
||||
|
@ -829,6 +832,7 @@ static void do_announce(Onion_Client *onion_c)
|
|||
client_send_announce_request(onion_c, 0, nodes_list[i].ip_port, nodes_list[i].client_id, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void do_onion_client(Onion_Client *onion_c)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user