[or-cvs] Fetch cached running-routers from servers that serve it (th...
Nick Mathewson
nickm at seul.org
Mon Nov 29 21:01:37 UTC 2004
Update of /home/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv31157/src/or
Modified Files:
directory.c or.h routerlist.c
Log Message:
Fetch cached running-routers from servers that serve it (that is, authdirservers, and servers running 0.0.9rc5-cvs or later.)
Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.175
retrieving revision 1.176
diff -u -d -r1.175 -r1.176
--- directory.c 29 Nov 2004 07:59:00 -0000 1.175
+++ directory.c 29 Nov 2004 21:01:34 -0000 1.176
@@ -152,21 +152,22 @@
trusted_dir_server_t *ds = NULL;
int fascistfirewall = get_options()->FascistFirewall;
- if (purpose == DIR_PURPOSE_FETCH_DIR) {
+ if (purpose == DIR_PURPOSE_FETCH_DIR ||
+ purpose == DIR_PURPOSE_FETCH_RUNNING_LIST) {
if (advertised_server_mode()) {
/* only ask authdirservers, and don't ask myself */
ds = router_pick_trusteddirserver(1, fascistfirewall);
} else {
/* anybody with a non-zero dirport will do */
- r = router_pick_directory_server(1, fascistfirewall);
+ r = router_pick_directory_server(1, fascistfirewall,
+ purpose==DIR_PURPOSE_FETCH_RUNNING_LIST);
if (!r) {
- log_fn(LOG_INFO, "No router found for directory; falling back to dirserver list");
+ log_fn(LOG_INFO, "No router found for %s; falling back to dirserver list",
+ purpose == DIR_PURPOSE_FETCH_RUNNING_LIST
+ ? "status list" : "directory");
ds = router_pick_trusteddirserver(1, fascistfirewall);
}
}
- } else if (purpose == DIR_PURPOSE_FETCH_RUNNING_LIST) {
- /* right now, running-routers isn't cached, so ask a trusted directory */
- ds = router_pick_trusteddirserver(0, fascistfirewall);
} else { // (purpose == DIR_PURPOSE_FETCH_RENDDESC)
/* only ask authdirservers, any of them will do */
/* Never use fascistfirewall; we're going via Tor. */
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.496
retrieving revision 1.497
diff -u -d -r1.496 -r1.497
--- or.h 29 Nov 2004 08:34:54 -0000 1.496
+++ or.h 29 Nov 2004 21:01:34 -0000 1.497
@@ -1560,7 +1560,7 @@
int router_reload_router_list(void);
void router_get_trusted_dir_servers(smartlist_t **outp);
-routerinfo_t *router_pick_directory_server(int requireothers, int fascistfirewall);
+routerinfo_t *router_pick_directory_server(int requireothers, int fascistfirewall, int for_running_routers);
trusted_dir_server_t *router_pick_trusteddirserver(int requireothers, int fascistfirewall);
int all_trusted_directory_servers_down(void);
struct smartlist_t;
Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.192
retrieving revision 1.193
diff -u -d -r1.192 -r1.193
--- routerlist.c 28 Nov 2004 11:39:53 -0000 1.192
+++ routerlist.c 29 Nov 2004 21:01:34 -0000 1.193
@@ -20,7 +20,8 @@
/* static function prototypes */
static routerinfo_t *
-router_pick_directory_server_impl(int requireothers, int fascistfirewall);
+router_pick_directory_server_impl(int requireothers, int fascistfirewall,
+ int for_runningrouters);
static trusted_dir_server_t *
router_pick_trusteddirserver_impl(int requireother, int fascistfirewall);
static void mark_all_trusteddirservers_up(void);
@@ -87,15 +88,20 @@
/** Try to find a running dirserver. If there are no running dirservers
* in our routerlist, set all the authoritative ones as running again,
* and pick one. If there are no dirservers at all in our routerlist,
- * reload the routerlist and try one last time. */
+ * reload the routerlist and try one last time. If for_runningrouters is
+ * true, then only pick a dirserver that can answer runningrouters queries
+ * (that is, a trusted dirserver, or one running 0.0.9rc5-cvs or later).
+ */
routerinfo_t *router_pick_directory_server(int requireothers,
- int fascistfirewall) {
+ int fascistfirewall,
+ int for_runningrouters) {
routerinfo_t *choice;
if (!routerlist)
return NULL;
- choice = router_pick_directory_server_impl(requireothers, fascistfirewall);
+ choice = router_pick_directory_server_impl(requireothers, fascistfirewall,
+ for_runningrouters);
if (choice)
return choice;
@@ -103,7 +109,8 @@
/* mark all authdirservers as up again */
mark_all_trusteddirservers_up();
/* try again */
- choice = router_pick_directory_server_impl(requireothers, fascistfirewall);
+ choice = router_pick_directory_server_impl(requireothers, fascistfirewall,
+ for_runningrouters);
if (choice)
return choice;
@@ -114,7 +121,8 @@
return NULL;
}
/* give it one last try */
- choice = router_pick_directory_server_impl(requireothers, 0);
+ choice = router_pick_directory_server_impl(requireothers, 0,
+ for_runningrouters);
return choice;
}
@@ -149,7 +157,8 @@
* it has to be a trusted server. If requireothers, it cannot be us.
*/
static routerinfo_t *
-router_pick_directory_server_impl(int requireothers, int fascistfirewall)
+router_pick_directory_server_impl(int requireothers, int fascistfirewall,
+ int for_runningrouters)
{
int i;
routerinfo_t *router;
@@ -175,6 +184,11 @@
if (!smartlist_string_isin(get_options()->FirewallPorts, buf))
continue;
}
+ /* before 0.0.9rc5-cvs, only trusted dirservers served status info. */
+ if (for_runningrouters &&
+ !(tor_version_as_new_as(router->platform,"0.0.9rc5-cvs") ||
+ router_digest_is_trusted_dir(router->identity_digest)))
+ continue;
smartlist_add(sl, router);
}
More information about the tor-commits
mailing list