diff options
author | irungentoo <irungentoo@gmail.com> | 2014-03-07 16:47:24 -0500 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-03-07 16:47:24 -0500 |
commit | 0e97836e016589805af4cd208bae64d97d244618 (patch) | |
tree | c6fb2bbdbc4513467b8167776ebe1ce7f4f3434c | |
parent | 48d757f46858b6faeae2f204802ffd4dc5020064 (diff) |
Fixed clients not connecting when there is only 2 people on the network.
-rw-r--r-- | toxcore/onion_client.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c index af209389..8c0e426a 100644 --- a/toxcore/onion_client.c +++ b/toxcore/onion_client.c | |||
@@ -519,7 +519,7 @@ int send_onion_data(Onion_Client *onion_c, int friend_num, uint8_t *data, uint32 | |||
519 | if ((uint32_t)len + crypto_box_PUBLICKEYBYTES != sizeof(packet)) | 519 | if ((uint32_t)len + crypto_box_PUBLICKEYBYTES != sizeof(packet)) |
520 | return -1; | 520 | return -1; |
521 | 521 | ||
522 | uint32_t i, good_nodes[MAX_ONION_CLIENTS], num_good = 0; | 522 | uint32_t i, good_nodes[MAX_ONION_CLIENTS], num_good = 0, num_nodes = 0; |
523 | Onion_Path path[MAX_ONION_CLIENTS]; | 523 | Onion_Path path[MAX_ONION_CLIENTS]; |
524 | Onion_Node *list_nodes = onion_c->friends_list[friend_num].clients_list; | 524 | Onion_Node *list_nodes = onion_c->friends_list[friend_num].clients_list; |
525 | 525 | ||
@@ -527,6 +527,7 @@ int send_onion_data(Onion_Client *onion_c, int friend_num, uint8_t *data, uint32 | |||
527 | if (is_timeout(list_nodes[i].timestamp, ONION_NODE_TIMEOUT)) | 527 | if (is_timeout(list_nodes[i].timestamp, ONION_NODE_TIMEOUT)) |
528 | continue; | 528 | continue; |
529 | 529 | ||
530 | ++num_nodes; | ||
530 | if (list_nodes[i].is_stored) { | 531 | if (list_nodes[i].is_stored) { |
531 | if (random_path(onion_c->dht, &onion_c->friends_list[friend_num].onion_paths, ~0, &path[num_good]) == -1) | 532 | if (random_path(onion_c->dht, &onion_c->friends_list[friend_num].onion_paths, ~0, &path[num_good]) == -1) |
532 | continue; | 533 | continue; |
@@ -536,7 +537,7 @@ int send_onion_data(Onion_Client *onion_c, int friend_num, uint8_t *data, uint32 | |||
536 | } | 537 | } |
537 | } | 538 | } |
538 | 539 | ||
539 | if (num_good < (MAX_ONION_CLIENTS / 4) + 1) | 540 | if (num_good < (num_nodes / 4) + 1) |
540 | return -1; | 541 | return -1; |
541 | 542 | ||
542 | uint32_t good = 0; | 543 | uint32_t good = 0; |