mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
non-dirservers expire routerinfo's that are more than a day old
svn:r1907
This commit is contained in:
parent
b6faca2268
commit
30a07b2ecd
@ -9,9 +9,6 @@
|
||||
* \brief Directory server core implementation.
|
||||
**/
|
||||
|
||||
/** How old do we allow a router to get before removing it? (seconds) */
|
||||
#define ROUTER_MAX_AGE (60*60*24)
|
||||
|
||||
/** How far in the future do we allow a router to get? (seconds) */
|
||||
#define ROUTER_ALLOW_SKEW (30*60)
|
||||
|
||||
|
@ -439,6 +439,7 @@ static void run_scheduled_events(time_t now) {
|
||||
if(!options.DirPort) {
|
||||
/* NOTE directory servers do not currently fetch directories.
|
||||
* Hope this doesn't bite us later. */
|
||||
routerlist_remove_old_routers(); /* purge obsolete entries */
|
||||
directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 0);
|
||||
} else {
|
||||
/* We're a directory; dump any old descriptors. */
|
||||
@ -451,7 +452,6 @@ static void run_scheduled_events(time_t now) {
|
||||
time_to_fetch_directory = now + options.DirFetchPostPeriod;
|
||||
}
|
||||
|
||||
|
||||
/** 2. Every second, we examine pending circuits and prune the
|
||||
* ones which have been pending for more than a few seconds.
|
||||
* We do this before step 3, so it can try building more if
|
||||
|
@ -128,6 +128,11 @@
|
||||
/** How often do we rotate TLS contexts? */
|
||||
#define MAX_SSL_KEY_LIFETIME (120*60)
|
||||
|
||||
/** How old do we allow a router to get before removing it, either
|
||||
* from the descriptor list (for dirservers) or the router list (for others)?
|
||||
* In seconds. */
|
||||
#define ROUTER_MAX_AGE (60*60*24)
|
||||
|
||||
#define CIRC_ID_TYPE_LOWER 0
|
||||
#define CIRC_ID_TYPE_HIGHER 1
|
||||
|
||||
@ -1298,6 +1303,7 @@ void routerlist_clear_trusted_directories(void);
|
||||
void routerinfo_free(routerinfo_t *router);
|
||||
routerinfo_t *routerinfo_copy(const routerinfo_t *router);
|
||||
void router_mark_as_down(char *nickname);
|
||||
void routerlist_remove_old_routers(void);
|
||||
int router_load_routerlist_from_file(char *routerfile, int trusted);
|
||||
int router_load_routerlist_from_string(const char *s, int trusted);
|
||||
int router_load_routerlist_from_directory(const char *s,crypto_pk_env_t *pkey);
|
||||
|
@ -348,6 +348,33 @@ int router_add_to_routerlist(routerinfo_t *router) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Remove any routers from the routerlist that are more than ROUTER_MAX_AGE
|
||||
* seconds old.
|
||||
*
|
||||
* (This function is just like dirserv_remove_old_servers. One day we should
|
||||
* merge them.)
|
||||
*/
|
||||
void
|
||||
routerlist_remove_old_routers(void)
|
||||
{
|
||||
int i;
|
||||
time_t cutoff;
|
||||
routerinfo_t *router;
|
||||
if (!routerlist)
|
||||
return;
|
||||
|
||||
cutoff = time(NULL) - ROUTER_MAX_AGE;
|
||||
for (i = 0; i < smartlist_len(routerlist->routers); ++i) {
|
||||
router = smartlist_get(routerlist->routers, i);
|
||||
if (router->published_on < cutoff) {
|
||||
/* Too old. Remove it. */
|
||||
log_fn(LOG_INFO,"Forgetting obsolete routerinfo for node %s.", router->nickname);
|
||||
routerinfo_free(router);
|
||||
smartlist_del(routerlist->routers, i--);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Code to parse router descriptors and directories.
|
||||
*/
|
||||
@ -440,7 +467,7 @@ int is_recommended_version(const char *myversion,
|
||||
}
|
||||
}
|
||||
|
||||
/** Replace the current routerlist with the routers stored in the
|
||||
/** Add to the current routerlist each router stored in the
|
||||
* signed directory <b>s</b>. If pkey is provided, make sure that <b>s</b> is
|
||||
* signed with pkey. */
|
||||
int router_load_routerlist_from_directory(const char *s, crypto_pk_env_t *pkey)
|
||||
|
Loading…
Reference in New Issue
Block a user