Added function to check if we were only connected to LAN DHT peers.

This commit is contained in:
irungentoo 2014-08-18 18:56:02 -04:00
parent 6ca7d86c50
commit c959f6c019
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
2 changed files with 29 additions and 0 deletions

View File

@ -2413,6 +2413,7 @@ int DHT_load(DHT *dht, const uint8_t *data, uint32_t length)
return -1;
}
/* return 0 if we are not connected to the DHT.
* return 1 if we are.
*/
@ -2431,3 +2432,25 @@ int DHT_isconnected(const DHT *dht)
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;
}

View File

@ -386,6 +386,12 @@ void kill_DHT(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);
#endif