summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2014-08-14 15:41:10 -0400
committerirungentoo <irungentoo@gmail.com>2014-08-14 15:41:10 -0400
commit5376d40f546bea84d25134a92f8d6e759189663e (patch)
tree20179a8afc91a97ce6528d571255b8763dc2a84b
parent1298932deb6c05a6ae525fc85159d4485c7be210 (diff)
tox_isconnected() now works on TCP only.
-rw-r--r--toxcore/onion_client.c16
-rw-r--r--toxcore/onion_client.h6
-rw-r--r--toxcore/tox.c2
3 files changed, 23 insertions, 1 deletions
diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c
index 6ad55218..719bd261 100644
--- a/toxcore/onion_client.c
+++ b/toxcore/onion_client.c
@@ -1274,3 +1274,19 @@ void kill_onion_client(Onion_Client *onion_c)
1274 memset(onion_c, 0, sizeof(Onion_Client)); 1274 memset(onion_c, 0, sizeof(Onion_Client));
1275 free(onion_c); 1275 free(onion_c);
1276} 1276}
1277
1278
1279/* return 0 if we are not connected to the network.
1280 * return 1 if we are.
1281 */
1282int onion_isconnected(const Onion_Client *onion_c)
1283{
1284 unsigned int i;
1285
1286 for (i = 0; i < MAX_ONION_CLIENTS; ++i) {
1287 if (!is_timeout(onion_c->clients_announce_list[i].timestamp, ONION_NODE_TIMEOUT))
1288 return 1;
1289 }
1290
1291 return 0;
1292}
diff --git a/toxcore/onion_client.h b/toxcore/onion_client.h
index 9d4d4832..61e0eca9 100644
--- a/toxcore/onion_client.h
+++ b/toxcore/onion_client.h
@@ -236,4 +236,10 @@ Onion_Client *new_onion_client(Net_Crypto *c);
236 236
237void kill_onion_client(Onion_Client *onion_c); 237void kill_onion_client(Onion_Client *onion_c);
238 238
239
240/* return 0 if we are not connected to the network.
241 * return 1 if we are.
242 */
243int onion_isconnected(const Onion_Client *onion_c);
244
239#endif 245#endif
diff --git a/toxcore/tox.c b/toxcore/tox.c
index 86a30d59..d352f672 100644
--- a/toxcore/tox.c
+++ b/toxcore/tox.c
@@ -796,7 +796,7 @@ int tox_bootstrap_from_address(Tox *tox, const char *address,
796int tox_isconnected(const Tox *tox) 796int tox_isconnected(const Tox *tox)
797{ 797{
798 const Messenger *m = tox; 798 const Messenger *m = tox;
799 return DHT_isconnected(m->dht); 799 return DHT_isconnected(m->dht) || onion_isconnected(m->onion_c);
800} 800}
801 801
802/* Return the time in milliseconds before tox_do() should be called again 802/* Return the time in milliseconds before tox_do() should be called again