Improved onion connection by a bit.

This commit is contained in:
irungentoo 2014-01-31 18:05:49 -05:00
parent 51717825c1
commit a377c7fbf4

View File

@ -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)
{