[or-cvs] non-dirservers expire routerinfo"s that are more than a day...
Roger Dingledine
arma at seul.org
Thu May 20 05:10:32 UTC 2004
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
dirserv.c main.c or.h routerlist.c
Log Message:
non-dirservers expire routerinfo's that are more than a day old
Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dirserv.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- dirserv.c 19 May 2004 19:42:50 -0000 1.51
+++ dirserv.c 20 May 2004 05:10:30 -0000 1.52
@@ -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)
Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.271
retrieving revision 1.272
diff -u -d -r1.271 -r1.272
--- main.c 19 May 2004 20:07:08 -0000 1.271
+++ main.c 20 May 2004 05:10:30 -0000 1.272
@@ -439,6 +439,7 @@
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 @@
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
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.353
retrieving revision 1.354
diff -u -d -r1.353 -r1.354
--- or.h 20 May 2004 04:16:43 -0000 1.353
+++ or.h 20 May 2004 05:10:30 -0000 1.354
@@ -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 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);
Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- routerlist.c 20 May 2004 02:42:50 -0000 1.79
+++ routerlist.c 20 May 2004 05:10:30 -0000 1.80
@@ -348,6 +348,33 @@
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 @@
}
}
-/** 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)
More information about the tor-commits
mailing list