Made onion paths expire eventually client side.

This commit is contained in:
irungentoo 2014-03-03 11:23:46 -05:00
parent 325395820d
commit 602c71bc17
2 changed files with 5 additions and 1 deletions

View File

@ -44,7 +44,8 @@ static int random_path(DHT *dht, Onion_Client_Paths *onion_paths, uint32_t pathn
if (pathnum >= NUMBER_ONION_PATHS)
pathnum = rand() % NUMBER_ONION_PATHS;
if (is_timeout(onion_paths->last_path_success[pathnum], ONION_PATH_TIMEOUT)) {
if (is_timeout(onion_paths->last_path_success[pathnum], ONION_PATH_TIMEOUT)
|| is_timeout(onion_paths->path_creation_time[pathnum], ONION_PATH_MAX_LIFETIME)) {
Node_format nodes[3];
if (random_nodes_path(dht, nodes, 3) != 3)
@ -54,6 +55,7 @@ static int random_path(DHT *dht, Onion_Client_Paths *onion_paths, uint32_t pathn
return -1;
onion_paths->last_path_success[pathnum] = unix_time() + ONION_PATH_FIRST_TIMEOUT - ONION_PATH_TIMEOUT;
onion_paths->path_creation_time[pathnum] = unix_time();
}
memcpy(path, &onion_paths->paths[pathnum], sizeof(Onion_Path));

View File

@ -39,6 +39,7 @@
then for all the next consecutive times */
#define ONION_PATH_FIRST_TIMEOUT 5
#define ONION_PATH_TIMEOUT 30
#define ONION_PATH_MAX_LIFETIME 600
/* A cheap way of making it take less bandwidth at startup:
by limiting the number of ping packets we can send per
@ -62,6 +63,7 @@ typedef struct {
typedef struct {
Onion_Path paths[NUMBER_ONION_PATHS];
uint64_t last_path_success[NUMBER_ONION_PATHS];
uint64_t path_creation_time[NUMBER_ONION_PATHS];
} Onion_Client_Paths;
typedef struct {