summaryrefslogtreecommitdiff
path: root/toxcore/onion_client.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/onion_client.c')
-rw-r--r--toxcore/onion_client.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c
index 24949aff..b774956c 100644
--- a/toxcore/onion_client.c
+++ b/toxcore/onion_client.c
@@ -1330,12 +1330,23 @@ void kill_onion_client(Onion_Client *onion_c)
1330 */ 1330 */
1331int onion_isconnected(const Onion_Client *onion_c) 1331int onion_isconnected(const Onion_Client *onion_c)
1332{ 1332{
1333 unsigned int i; 1333 unsigned int i, num = 0, announced = 0;
1334 1334
1335 for (i = 0; i < MAX_ONION_CLIENTS; ++i) { 1335 for (i = 0; i < MAX_ONION_CLIENTS; ++i) {
1336 if (!is_timeout(onion_c->clients_announce_list[i].timestamp, ONION_NODE_TIMEOUT)) 1336 if (!is_timeout(onion_c->clients_announce_list[i].timestamp, ONION_NODE_TIMEOUT)) {
1337 if (onion_c->clients_announce_list[i].is_stored) 1337 ++num;
1338 return 1; 1338
1339 if (onion_c->clients_announce_list[i].is_stored) {
1340 ++announced;
1341 }
1342 }
1343 }
1344
1345 /* Consider ourselves online if we are announced to half or more nodes
1346 we are connected to */
1347 if (num && announced) {
1348 if ((num / 2) <= announced)
1349 return 1;
1339 } 1350 }
1340 1351
1341 return 0; 1352 return 0;