Fetch cached running-routers from servers that serve it (that is, authdirservers, and servers running 0.0.9rc5-cvs or later.)

svn:r3018
This commit is contained in:
Nick Mathewson 2004-11-29 21:01:34 +00:00
parent b6b07d1d98
commit aff5122685
4 changed files with 34 additions and 17 deletions

View File

@ -12,12 +12,14 @@ ARMA - arma claims
For 0.0.9: For 0.0.9:
N&R- bring tor-spec up to date N&R- bring tor-spec up to date
N . cache and serve running-routers on other nodes? o cache and serve running-routers on other nodes?
. cache running-routers o cache running-routers
- download running-routers from servers running rc5-cvs or later o download running-routers from servers running rc5-cvs or later
N - pump up periods for fetching things; figure out how to do this N - pump up periods for fetching things; figure out how to do this
backward-compatibily, so that people who did set dirfetchpostperiod backward-compatibily, so that people who did set dirfetchpostperiod
get the right behavior. get the right behavior.
- If dirport is set, we should have a maximum dirfetchperiod and
a maximum statusfetchperiod, or else we'll serve very stale stuff.
N - Adapt version parsing code to handle new version scheme; document new N - Adapt version parsing code to handle new version scheme; document new
version scheme. version scheme.
N&R. make loglevels info,debug less noisy N&R. make loglevels info,debug less noisy

View File

@ -152,21 +152,22 @@ directory_get_from_dirserver(uint8_t purpose, const char *resource)
trusted_dir_server_t *ds = NULL; trusted_dir_server_t *ds = NULL;
int fascistfirewall = get_options()->FascistFirewall; 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()) { if (advertised_server_mode()) {
/* only ask authdirservers, and don't ask myself */ /* only ask authdirservers, and don't ask myself */
ds = router_pick_trusteddirserver(1, fascistfirewall); ds = router_pick_trusteddirserver(1, fascistfirewall);
} else { } else {
/* anybody with a non-zero dirport will do */ /* 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) { 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); 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) } else { // (purpose == DIR_PURPOSE_FETCH_RENDDESC)
/* only ask authdirservers, any of them will do */ /* only ask authdirservers, any of them will do */
/* Never use fascistfirewall; we're going via Tor. */ /* Never use fascistfirewall; we're going via Tor. */

View File

@ -1560,7 +1560,7 @@ typedef struct trusted_dir_server_t {
int router_reload_router_list(void); int router_reload_router_list(void);
void router_get_trusted_dir_servers(smartlist_t **outp); 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); trusted_dir_server_t *router_pick_trusteddirserver(int requireothers, int fascistfirewall);
int all_trusted_directory_servers_down(void); int all_trusted_directory_servers_down(void);
struct smartlist_t; struct smartlist_t;

View File

@ -20,7 +20,8 @@ static smartlist_t *trusted_dir_servers = NULL;
/* static function prototypes */ /* static function prototypes */
static routerinfo_t * 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 * static trusted_dir_server_t *
router_pick_trusteddirserver_impl(int requireother, int fascistfirewall); router_pick_trusteddirserver_impl(int requireother, int fascistfirewall);
static void mark_all_trusteddirservers_up(void); static void mark_all_trusteddirservers_up(void);
@ -87,15 +88,20 @@ void router_get_trusted_dir_servers(smartlist_t **outp)
/** Try to find a running dirserver. If there are no running dirservers /** Try to find a running dirserver. If there are no running dirservers
* in our routerlist, set all the authoritative ones as running again, * in our routerlist, set all the authoritative ones as running again,
* and pick one. If there are no dirservers at all in our routerlist, * 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, routerinfo_t *router_pick_directory_server(int requireothers,
int fascistfirewall) { int fascistfirewall,
int for_runningrouters) {
routerinfo_t *choice; routerinfo_t *choice;
if (!routerlist) if (!routerlist)
return NULL; return NULL;
choice = router_pick_directory_server_impl(requireothers, fascistfirewall); choice = router_pick_directory_server_impl(requireothers, fascistfirewall,
for_runningrouters);
if (choice) if (choice)
return choice; return choice;
@ -103,7 +109,8 @@ routerinfo_t *router_pick_directory_server(int requireothers,
/* mark all authdirservers as up again */ /* mark all authdirservers as up again */
mark_all_trusteddirservers_up(); mark_all_trusteddirservers_up();
/* try again */ /* try again */
choice = router_pick_directory_server_impl(requireothers, fascistfirewall); choice = router_pick_directory_server_impl(requireothers, fascistfirewall,
for_runningrouters);
if (choice) if (choice)
return choice; return choice;
@ -114,7 +121,8 @@ routerinfo_t *router_pick_directory_server(int requireothers,
return NULL; return NULL;
} }
/* give it one last try */ /* 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; return choice;
} }
@ -149,7 +157,8 @@ trusted_dir_server_t *router_pick_trusteddirserver(int requireothers,
* it has to be a trusted server. If requireothers, it cannot be us. * it has to be a trusted server. If requireothers, it cannot be us.
*/ */
static routerinfo_t * 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; int i;
routerinfo_t *router; routerinfo_t *router;
@ -175,6 +184,11 @@ router_pick_directory_server_impl(int requireothers, int fascistfirewall)
if (!smartlist_string_isin(get_options()->FirewallPorts, buf)) if (!smartlist_string_isin(get_options()->FirewallPorts, buf))
continue; 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); smartlist_add(sl, router);
} }