Upload to trusted dir servers based on DirServer config options, not on routerinfos.

svn:r2529
This commit is contained in:
Nick Mathewson 2004-10-15 19:04:38 +00:00
parent 01eacbca9e
commit 28dd458eaf
3 changed files with 30 additions and 18 deletions

View File

@ -73,28 +73,27 @@ void
directory_post_to_dirservers(uint8_t purpose, const char *payload,
size_t payload_len)
{
int i;
smartlist_t *dirservers;
routerinfo_t *router;
routerlist_t *rl;
char buf[16];
router_get_routerlist(&rl);
if(!rl)
return;
for(i=0; i < smartlist_len(rl->routers); i++) {
router = smartlist_get(rl->routers, i);
/* Note: this posts our descriptor to ourselves, if we're an
* authdirserver. But I think that's ok. */
if(!router->is_trusted_dir)
continue;
if (options.FascistFirewall && purpose == DIR_PURPOSE_UPLOAD_DIR) {
sprintf(buf,"%d",router->dir_port);
router_get_trusted_dir_servers(&dirservers);
tor_assert(dirservers);
SMARTLIST_FOREACH(dirservers, trusted_dir_server_t *, ds,
{
/* Pay attention to fascistfirewall when we're uploading a
* router descriptor, but not when uploading a service
* descriptor -- those use Tor. */
if (options.FascistFirewall && purpose == DIR_PURPOSE_UPLOAD_DIR &&
!options.HttpProxy) {
sprintf(buf,"%d",ds->dir_port);
if (!smartlist_string_isin(options.FirewallPorts, buf))
continue;
}
directory_initiate_command_router(router, purpose, payload, payload_len);
}
directory_initiate_command_trusted_dir(ds, purpose, payload, payload_len);
});
}
/** Start a connection to a random running directory server, using

View File

@ -1413,6 +1413,7 @@ typedef struct trusted_dir_server_t {
} trusted_dir_server_t;
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);
trusted_dir_server_t *router_pick_trusteddirserver(int requireothers, int fascistfirewall);
int all_trusted_directory_servers_down(void);

View File

@ -69,6 +69,18 @@ int router_reload_router_list(void)
return 0;
}
/* Set *<b>outp</b> to a smartlist containing a list of
* trusted_dir_server_t * for all known trusted dirservers. Callers
* must not modify the list or its contents.
*/
void router_get_trusted_dir_servers(smartlist_t **outp)
{
if (!trusted_dir_servers)
trusted_dir_servers = smartlist_create();
*outp = trusted_dir_servers;
}
/** 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,