aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2007-06-09 07:05:19 +0000
committerRoger Dingledine <arma@torproject.org>2007-06-09 07:05:19 +0000
commita97c3b8c2da5d1f1e0ac793e7ad79b8288a87bc3 (patch)
tree9d36eb6c00798193c27192fba6bfc34ab2e0775c /src
parent8dfde75ef68afe952058aa938f53707f98b9178c (diff)
downloadtor-a97c3b8c2da5d1f1e0ac793e7ad79b8288a87bc3.tar.gz
tor-a97c3b8c2da5d1f1e0ac793e7ad79b8288a87bc3.zip
Be clearer on the various roles for auth dir types.
Bridge authorities no longer write bridge descriptors to their cached-routers file -- this gets complex because of extrainfo documents. svn:r10545
Diffstat (limited to 'src')
-rw-r--r--src/or/config.c3
-rw-r--r--src/or/connection_or.c2
-rw-r--r--src/or/directory.c4
-rw-r--r--src/or/dirserv.c24
-rw-r--r--src/or/main.c4
-rw-r--r--src/or/or.h5
-rw-r--r--src/or/router.c24
7 files changed, 54 insertions, 12 deletions
diff --git a/src/or/config.c b/src/or/config.c
index 97e1a50020..1a04c311e7 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -3713,7 +3713,8 @@ parse_dir_server_line(const char *line, int validate_only)
fingerprint = smartlist_join_strings(items, "", 0, NULL);
if (strlen(fingerprint) != HEX_DIGEST_LEN) {
- log_warn(LD_CONFIG, "Key digest for DirServer is wrong length.");
+ log_warn(LD_CONFIG, "Key digest for DirServer is wrong length %d.",
+ (int)strlen(fingerprint));
goto err;
}
if (base16_decode(digest, DIGEST_LEN, fingerprint, HEX_DIGEST_LEN)<0) {
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index b0b8b80311..817f491349 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -676,7 +676,7 @@ connection_or_check_valid_handshake(or_connection_t *conn, int started_here,
END_OR_CONN_REASON_OR_IDENTITY);
as_advertised = 0;
}
- if (authdir_mode_handles_descs(options)) {
+ if (authdir_mode_tests_reachability(options)) {
/* We initiated this connection to address:port. Drop all routers
* with the same address:port and a different key.
*/
diff --git a/src/or/directory.c b/src/or/directory.c
index 3290b0f4f8..a0ed7393ed 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1997,7 +1997,9 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
if (authdir_mode_handles_descs(options) &&
!strcmp(url,"/tor/")) { /* server descriptor post */
const char *msg = NULL;
- int r = dirserv_add_multiple_descriptors(body, &msg);
+ uint8_t purpose = authdir_mode_bridge(options) ?
+ ROUTER_PURPOSE_CONTROLLER : ROUTER_PURPOSE_GENERAL;
+ int r = dirserv_add_multiple_descriptors(body, purpose, &msg);
tor_assert(msg);
if (r > 0)
dirserv_get_directory(); /* rebuild and write to disk */
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index b00f68dab8..2bc99e261a 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -515,7 +515,8 @@ authdir_wants_to_reject_router(routerinfo_t *ri, const char **msg,
/** As for dirserv_add_descriptor, but accepts multiple documents, and
* returns the most severe error that occurred for any one of them. */
int
-dirserv_add_multiple_descriptors(const char *desc, const char **msg)
+dirserv_add_multiple_descriptors(const char *desc, uint8_t purpose,
+ const char **msg)
{
int r=100; /* higher than any actual return value. */
int r_tmp;
@@ -530,6 +531,17 @@ dirserv_add_multiple_descriptors(const char *desc, const char **msg)
if (!router_parse_list_from_string(&s, NULL, list, SAVED_NOWHERE, 0)) {
SMARTLIST_FOREACH(list, routerinfo_t *, ri, {
msg_out = NULL;
+
+ /* Assign the purpose.
+ * XXX020 Perhaps this should get pushed into
+ * router_parse_list_from_string()? Also, tie it somehow into
+ * router_load_single_router()? Lastly, does extrainfo_t want
+ * a purpose field too, or can we just piggyback off the one
+ * in routerinfo_t? */
+ ri->purpose = purpose;
+ if (purpose != ROUTER_PURPOSE_GENERAL)
+ ri->cache_info.do_not_cache = 1;
+
r_tmp = dirserv_add_descriptor(ri, &msg_out);
if (r_tmp < r) {
r = r_tmp;
@@ -544,6 +556,11 @@ dirserv_add_multiple_descriptors(const char *desc, const char **msg)
if (!router_parse_list_from_string(&s, NULL, list, SAVED_NOWHERE, 1)) {
SMARTLIST_FOREACH(list, extrainfo_t *, ei, {
msg_out = NULL;
+
+ /* XXX020 see above note on purpose fields */
+ if (purpose != ROUTER_PURPOSE_GENERAL)
+ ei->cache_info.do_not_cache = 1;
+
r_tmp = dirserv_add_extrainfo(ei, &msg_out);
if (r_tmp < r) {
r = r_tmp;
@@ -842,7 +859,7 @@ list_server_status(smartlist_t *routers, char **router_status_out,
or_options_t *options = get_options();
/* We include v2 dir auths here too, because they need to answer
* controllers. Eventually we'll deprecate this whole function. */
- int authdir = authdir_mode_handles_descs(options);
+ int authdir = authdir_mode_publishes_statuses(options);
tor_assert(router_status_out);
rs_entries = smartlist_create();
@@ -1260,8 +1277,9 @@ dirserv_pick_cached_dir_obj(cached_dir_t *cache_src,
or_options_t *options = get_options();
int authority = (auth_type == V1_AUTHORITY && authdir_mode_v1(options)) ||
(auth_type == V2_AUTHORITY && authdir_mode_v2(options));
+ /* XXX020 eventually use authdir_mode_publishes_statuses() here */
- if (!authority || authdir_mode_bridge(options)) { /* XXX020 */
+ if (!authority || authdir_mode_bridge(options)) {
return cache_src;
} else {
/* We're authoritative. */
diff --git a/src/or/main.c b/src/or/main.c
index 3608b1791b..ef72f49ab4 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -916,7 +916,7 @@ run_scheduled_events(time_t now)
if (accounting_is_enabled(options))
accounting_run_housekeeping(now);
- if (now % 10 == 0 && (authdir_mode_handles_descs(options)) &&
+ if (now % 10 == 0 && (authdir_mode_tests_reachability(options)) &&
!we_are_hibernating()) {
/* try to determine reachability of the other Tor servers */
dirserv_test_reachability(0);
@@ -1329,7 +1329,7 @@ do_main_loop(void)
}
directory_info_has_arrived(time(NULL),1);
- if (authdir_mode_handles_descs(get_options())) {
+ if (authdir_mode_tests_reachability(get_options())) {
/* the directory is already here, run startup things */
dirserv_test_reachability(1);
}
diff --git a/src/or/or.h b/src/or/or.h
index 7d199fa6b8..7220800db8 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -2684,7 +2684,8 @@ int dirserv_add_own_fingerprint(const char *nickname, crypto_pk_env_t *pk);
int dirserv_load_fingerprint_file(void);
void dirserv_free_fingerprint_list(void);
const char *dirserv_get_nickname_by_digest(const char *digest);
-int dirserv_add_multiple_descriptors(const char *desc, const char **msg);
+int dirserv_add_multiple_descriptors(const char *desc, uint8_t purpose,
+ const char **msg);
int dirserv_add_descriptor(routerinfo_t *ri, const char **msg);
int getinfo_helper_dirserv_unregistered(control_connection_t *conn,
const char *question, char **answer);
@@ -3127,6 +3128,8 @@ int authdir_mode(or_options_t *options);
int authdir_mode_v1(or_options_t *options);
int authdir_mode_v2(or_options_t *options);
int authdir_mode_handles_descs(or_options_t *options);
+int authdir_mode_publishes_statuses(or_options_t *options);
+int authdir_mode_tests_reachability(or_options_t *options);
int authdir_mode_bridge(or_options_t *options);
int clique_mode(or_options_t *options);
int server_mode(or_options_t *options);
diff --git a/src/or/router.c b/src/or/router.c
index db433f5b52..7571b30da6 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -714,12 +714,30 @@ authdir_mode_v2(or_options_t *options)
return authdir_mode(options) && options->V2AuthoritativeDir != 0;
}
/** Return true iff we are an authoritative directory server that
- * handles descriptors -- including receiving posts, creating directories,
- * and testing reachability.
+ * is willing to receive or serve descriptors on its dirport.
*/
int
authdir_mode_handles_descs(or_options_t *options)
{
+ return authdir_mode_v1(options) || authdir_mode_v2(options) ||
+ authdir_mode_bridge(options);
+}
+/** Return true iff we are an authoritative directory server that
+ * publishes its own network statuses.
+ */
+int
+authdir_mode_publishes_statuses(or_options_t *options)
+{
+ if (authdir_mode_bridge(options))
+ return 0;
+ return authdir_mode_v1(options) || authdir_mode_v2(options);
+}
+/** Return true iff we are an authoritative directory server that
+ * tests reachability of the descriptors it learns about.
+ */
+int
+authdir_mode_tests_reachability(or_options_t *options)
+{
return authdir_mode_v1(options) || authdir_mode_v2(options);
}
/** Return true iff we believe ourselves to be a bridge authoritative
@@ -735,7 +753,7 @@ authdir_mode_bridge(or_options_t *options)
int
clique_mode(or_options_t *options)
{
- return authdir_mode_handles_descs(options);
+ return authdir_mode_tests_reachability(options);
}
/** Return true iff we are trying to be a server.