aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/or/directory.c35
-rw-r--r--src/or/or.h1
-rw-r--r--src/or/routerlist.c12
3 files changed, 30 insertions, 18 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index 7726d3371..803aefe79 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -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);
- if (!smartlist_string_isin(options.FirewallPorts, buf))
- continue;
- }
- directory_initiate_command_router(router, purpose, payload, payload_len);
- }
+ 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_trusted_dir(ds, purpose, payload, payload_len);
+ });
}
/** Start a connection to a random running directory server, using
diff --git a/src/or/or.h b/src/or/or.h
index ff2a2957d..0f831536a 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -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);
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index b16847e62..18eb9a618 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -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,