summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-12-18 23:45:24 +0000
committerNick Mathewson <nickm@torproject.org>2007-12-18 23:45:24 +0000
commitd07122ba4741897967d110b10ed8ca0441cc6397 (patch)
tree9622be8f97b48243a4dff53e380fcc68f73fe523
parent076097281dde078149ed789cf3df0ef6ecce815d (diff)
downloadtor-d07122ba4741897967d110b10ed8ca0441cc6397.tar.gz
tor-d07122ba4741897967d110b10ed8ca0441cc6397.zip
r17246@catbus: nickm | 2007-12-18 18:45:17 -0500
Fix some xxx020 items. svn:r12864
-rw-r--r--ChangeLog2
-rw-r--r--src/or/directory.c2
-rw-r--r--src/or/dirvote.c6
-rw-r--r--src/or/main.c2
-rw-r--r--src/or/or.h2
-rw-r--r--src/or/router.c23
-rw-r--r--src/or/routerlist.c9
7 files changed, 29 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index b34ef3086d..361c0aaecd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -76,6 +76,8 @@ Changes in version 0.2.0.13-alpha - 2007-12-??
in really weird results on platforms whose sys/types.h files define
nonstandard integer types.
- Fix compilation with --disable-threads set.
+ - Authorities decide whether they're authoritative for a given router
+ based on the router's purpose.
o Minor features:
- On USR1, when dmalloc is in use, log the top 10 memory
diff --git a/src/or/directory.c b/src/or/directory.c
index b211414137..02c411d499 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -2703,7 +2703,7 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
return 0;
}
- if (authdir_mode_handles_descs(options) &&
+ if (authdir_mode_handles_descs(options, -1) &&
!strcmp(url,"/tor/")) { /* server descriptor post */
const char *msg = NULL;
uint8_t purpose = authdir_mode_bridge(options) ?
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index 9734880f63..7201af804a 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -46,8 +46,10 @@ format_networkstatus_vote(crypto_pk_env_t *private_signing_key,
MAX_NICKNAME_LEN+BASE64_DIGEST_LEN*2+ISO_TIME_LEN+INET_NTOA_BUF_LEN+ \
5*2 /* ports */ + 10 /* punctuation */ + \
/* second line */ \
- (LONGEST_STATUS_FLAG_NAME_LEN+1)*N_STATUS_FLAGS + 2)
-/* XXX020 RS_ENTRY_LEN should probably include space for v lines */
+ (LONGEST_STATUS_FLAG_NAME_LEN+1)*N_STATUS_FLAGS + 2 + \
+ /* v line. XXXX020 not accurate! */ \
+ 80 \
+ )
size_t len;
char *status = NULL;
diff --git a/src/or/main.c b/src/or/main.c
index 6aaa4c45e0..620edad426 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1295,7 +1295,7 @@ do_hup(void)
return -1;
}
options = get_options(); /* they have changed now */
- if (authdir_mode_handles_descs(options)) {
+ if (authdir_mode_handles_descs(options, -1)) {
/* reload the approved-routers file */
if (dirserv_load_fingerprint_file() < 0) {
/* warnings are logged from dirserv_load_fingerprint_file() directly */
diff --git a/src/or/or.h b/src/or/or.h
index a59e7459b2..682d83d019 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -3718,7 +3718,7 @@ 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_v3(or_options_t *options);
-int authdir_mode_handles_descs(or_options_t *options);
+int authdir_mode_handles_descs(or_options_t *options, int purpose);
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);
diff --git a/src/or/router.c b/src/or/router.c
index 779e54e357..2cacb5f031 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -834,13 +834,22 @@ authdir_mode_any_nonhidserv(or_options_t *options)
options->V2AuthoritativeDir ||
options->V3AuthoritativeDir);
}
-/** Return true iff we are an authoritative directory server that
- * is willing to receive or serve descriptors on its dirport.
- */
+/** Return true iff we are an authoritative directory server that is
+ * authoritative about receiving and serving descriptors of type
+ * <b>purpose</b> its dirport. Use -1 for "any purpose". */
int
-authdir_mode_handles_descs(or_options_t *options)
-{
- return authdir_mode_any_nonhidserv(options);
+authdir_mode_handles_descs(or_options_t *options, int purpose)
+{
+ if (purpose < 0)
+ return authdir_mode_any_nonhidserv(options);
+ else if (purpose == ROUTER_PURPOSE_GENERAL)
+ return (options->V1AuthoritativeDir ||
+ options->V2AuthoritativeDir ||
+ options->V3AuthoritativeDir);
+ else if (purpose == ROUTER_PURPOSE_BRIDGE)
+ return (options->BridgeAuthoritativeDir);
+ else
+ return 0;
}
/** Return true iff we are an authoritative directory server that
* publishes its own network statuses.
@@ -858,7 +867,7 @@ authdir_mode_publishes_statuses(or_options_t *options)
int
authdir_mode_tests_reachability(or_options_t *options)
{
- return authdir_mode_handles_descs(options);
+ return authdir_mode_handles_descs(options, -1);
}
/** Return true iff we believe ourselves to be a bridge authoritative
* directory server.
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index e96aa2afef..a9a43c9ba3 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -2624,7 +2624,7 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
int from_cache, int from_fetch)
{
const char *id_digest;
- int authdir = authdir_mode(get_options());
+ int authdir = authdir_mode_handles_descs(get_options(), router->purpose);
int authdir_believes_valid = 0;
routerinfo_t *old_router;
networkstatus_vote_t *consensus = networkstatus_get_latest_consensus();
@@ -2706,7 +2706,7 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
}
if (router->purpose == ROUTER_PURPOSE_GENERAL &&
- consensus && !in_consensus && !authdir_mode(get_options())) {
+ consensus && !in_consensus && !authdir) {
/* If it's a general router not listed in the consensus, then don't
* consider replacing the latest router with it. */
if (!from_cache && should_cache_old_descriptors())
@@ -3830,9 +3830,8 @@ update_consensus_router_descriptor_downloads(time_t now)
smartlist_add(downloadable, rs->descriptor_digest);
});
- if (!authdir_mode_handles_descs(options) && smartlist_len(no_longer_old)) {
- /* XXX020 Nick: where do authorities decide never to put stuff in old?
- * We should make sure bridge descriptors do that too. */
+ if (!authdir_mode_handles_descs(options, ROUTER_PURPOSE_GENERAL)
+ && smartlist_len(no_longer_old)) {
routerlist_t *rl = router_get_routerlist();
log_info(LD_DIR, "%d router descriptors listed in consensus are "
"currently in old_routers; making them current.",