mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Added function to check if we were only connected to LAN DHT peers.
This commit is contained in:
parent
6ca7d86c50
commit
c959f6c019
|
@ -2413,6 +2413,7 @@ int DHT_load(DHT *dht, const uint8_t *data, uint32_t length)
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return 0 if we are not connected to the DHT.
|
/* return 0 if we are not connected to the DHT.
|
||||||
* return 1 if we are.
|
* return 1 if we are.
|
||||||
*/
|
*/
|
||||||
|
@ -2431,3 +2432,25 @@ int DHT_isconnected(const DHT *dht)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* return 0 if we are not connected or only connected to lan peers with the DHT.
|
||||||
|
* return 1 if we are.
|
||||||
|
*/
|
||||||
|
int DHT_non_lan_connected(const DHT *dht)
|
||||||
|
{
|
||||||
|
uint32_t i;
|
||||||
|
unix_time_update();
|
||||||
|
|
||||||
|
for (i = 0; i < LCLIENT_LIST; ++i) {
|
||||||
|
const Client_data *client = &dht->close_clientlist[i];
|
||||||
|
|
||||||
|
if (!is_timeout(client->assoc4.timestamp, BAD_NODE_TIMEOUT) && LAN_ip(client->assoc4.ip_port.ip) == -1)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (!is_timeout(client->assoc6.timestamp, BAD_NODE_TIMEOUT) && LAN_ip(client->assoc6.ip_port.ip) == -1)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -386,6 +386,12 @@ void kill_DHT(DHT *dht);
|
||||||
*/
|
*/
|
||||||
int DHT_isconnected(const DHT *dht);
|
int DHT_isconnected(const DHT *dht);
|
||||||
|
|
||||||
|
/* return 0 if we are not connected or only connected to lan peers with the DHT.
|
||||||
|
* return 1 if we are.
|
||||||
|
*/
|
||||||
|
int DHT_non_lan_connected(const DHT *dht);
|
||||||
|
|
||||||
|
|
||||||
int addto_lists(DHT *dht, IP_Port ip_port, const uint8_t *client_id);
|
int addto_lists(DHT *dht, IP_Port ip_port, const uint8_t *client_id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user