Skip to content

Commit

Permalink
tox_isconnected() now works on TCP only.
Browse files Browse the repository at this point in the history
  • Loading branch information
irungentoo committed Aug 14, 2014
1 parent 1298932 commit 5376d40
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
16 changes: 16 additions & 0 deletions toxcore/onion_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1274,3 +1274,19 @@ void kill_onion_client(Onion_Client *onion_c)
memset(onion_c, 0, sizeof(Onion_Client));
free(onion_c);
}


/* return 0 if we are not connected to the network.
* return 1 if we are.
*/
int onion_isconnected(const Onion_Client *onion_c)
{
unsigned int i;

for (i = 0; i < MAX_ONION_CLIENTS; ++i) {
if (!is_timeout(onion_c->clients_announce_list[i].timestamp, ONION_NODE_TIMEOUT))
return 1;
}

return 0;
}
6 changes: 6 additions & 0 deletions toxcore/onion_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,10 @@ Onion_Client *new_onion_client(Net_Crypto *c);

void kill_onion_client(Onion_Client *onion_c);


/* return 0 if we are not connected to the network.
* return 1 if we are.
*/
int onion_isconnected(const Onion_Client *onion_c);

#endif
2 changes: 1 addition & 1 deletion toxcore/tox.c
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ int tox_bootstrap_from_address(Tox *tox, const char *address,
int tox_isconnected(const Tox *tox)
{
const Messenger *m = tox;
return DHT_isconnected(m->dht);
return DHT_isconnected(m->dht) || onion_isconnected(m->onion_c);
}

/* Return the time in milliseconds before tox_do() should be called again
Expand Down

0 comments on commit 5376d40

Please sign in to comment.