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.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c
index a9fc1643..ed328fb3 100644
--- a/toxcore/onion_client.c
+++ b/toxcore/onion_client.c
@@ -1425,7 +1425,6 @@ void do_onion_client(Onion_Client *onion_c)
1425 ++onion_c->onion_connected; 1425 ++onion_c->onion_connected;
1426 } 1426 }
1427 1427
1428 onion_c->UDP_connected = DHT_non_lan_connected(onion_c->dht);
1429 } else { 1428 } else {
1430 populate_path_nodes_tcp(onion_c); 1429 populate_path_nodes_tcp(onion_c);
1431 1430
@@ -1434,12 +1433,22 @@ void do_onion_client(Onion_Client *onion_c)
1434 } 1433 }
1435 } 1434 }
1436 1435
1436 onion_c->UDP_connected = DHT_non_lan_connected(onion_c->dht);
1437
1438 if (is_timeout(onion_c->first_run, ONION_CONNECTION_SECONDS)) {
1439 set_tcp_onion_status(onion_c->c->tcp_c, !onion_c->UDP_connected);
1440 }
1441
1437 if (onion_connection_status(onion_c)) { 1442 if (onion_connection_status(onion_c)) {
1438 for (i = 0; i < onion_c->num_friends; ++i) { 1443 for (i = 0; i < onion_c->num_friends; ++i) {
1439 do_friend(onion_c, i); 1444 do_friend(onion_c, i);
1440 } 1445 }
1441 } 1446 }
1442 1447
1448 if (onion_c->last_run == 0) {
1449 onion_c->first_run = unix_time();
1450 }
1451
1443 onion_c->last_run = unix_time(); 1452 onion_c->last_run = unix_time();
1444} 1453}
1445 1454
@@ -1467,7 +1476,7 @@ Onion_Client *new_onion_client(Net_Crypto *c)
1467 networking_registerhandler(onion_c->net, NET_PACKET_ONION_DATA_RESPONSE, &handle_data_response, onion_c); 1476 networking_registerhandler(onion_c->net, NET_PACKET_ONION_DATA_RESPONSE, &handle_data_response, onion_c);
1468 oniondata_registerhandler(onion_c, ONION_DATA_DHTPK, &handle_dhtpk_announce, onion_c); 1477 oniondata_registerhandler(onion_c, ONION_DATA_DHTPK, &handle_dhtpk_announce, onion_c);
1469 cryptopacket_registerhandler(onion_c->dht, CRYPTO_PACKET_DHTPK, &handle_dht_dhtpk, onion_c); 1478 cryptopacket_registerhandler(onion_c->dht, CRYPTO_PACKET_DHTPK, &handle_dht_dhtpk, onion_c);
1470 tcp_onion_response_handler(onion_c->c, &handle_tcp_onion, onion_c); 1479 set_onion_packet_tcp_connection_callback(onion_c->c->tcp_c, &handle_tcp_onion, onion_c);
1471 1480
1472 return onion_c; 1481 return onion_c;
1473} 1482}
@@ -1483,7 +1492,7 @@ void kill_onion_client(Onion_Client *onion_c)
1483 networking_registerhandler(onion_c->net, NET_PACKET_ONION_DATA_RESPONSE, NULL, NULL); 1492 networking_registerhandler(onion_c->net, NET_PACKET_ONION_DATA_RESPONSE, NULL, NULL);
1484 oniondata_registerhandler(onion_c, ONION_DATA_DHTPK, NULL, NULL); 1493 oniondata_registerhandler(onion_c, ONION_DATA_DHTPK, NULL, NULL);
1485 cryptopacket_registerhandler(onion_c->dht, CRYPTO_PACKET_DHTPK, NULL, NULL); 1494 cryptopacket_registerhandler(onion_c->dht, CRYPTO_PACKET_DHTPK, NULL, NULL);
1486 tcp_onion_response_handler(onion_c->c, NULL, NULL); 1495 set_onion_packet_tcp_connection_callback(onion_c->c->tcp_c, NULL, NULL);
1487 memset(onion_c, 0, sizeof(Onion_Client)); 1496 memset(onion_c, 0, sizeof(Onion_Client));
1488 free(onion_c); 1497 free(onion_c);
1489} 1498}