aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-10-08 17:44:19 +0000
committerNick Mathewson <nickm@torproject.org>2007-10-08 17:44:19 +0000
commit84d7677a8a4af82c9c68cada79ddecc13a628f66 (patch)
treef056455b0a2e522b6cbc5a79cfd0f35c7edc75ab /src/or
parent3f6e3ce61b9923477c93e2429ff34d185d898bd9 (diff)
downloadtor-84d7677a8a4af82c9c68cada79ddecc13a628f66.tar
tor-84d7677a8a4af82c9c68cada79ddecc13a628f66.tar.gz
r14770@Kushana: nickm | 2007-10-08 11:43:02 -0400
Make router_digest_is_trusted_dir able to check for type. When looking for a V3 directory, only assume that the V3 authorities and caches have it: previous code assumed that all authorities had it. svn:r11789
Diffstat (limited to 'src/or')
-rw-r--r--src/or/or.h5
-rw-r--r--src/or/routerlist.c20
2 files changed, 17 insertions, 8 deletions
diff --git a/src/or/or.h b/src/or/or.h
index e049ab444..016d13a9d 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -3495,7 +3495,10 @@ signed_descriptor_t *router_get_by_extrainfo_digest(const char *digest);
signed_descriptor_t *extrainfo_get_by_descriptor_digest(const char *digest);
const char *signed_descriptor_get_body(signed_descriptor_t *desc);
int router_digest_version_as_new_as(const char *digest, const char *cutoff);
-int router_digest_is_trusted_dir(const char *digest);
+int router_digest_is_trusted_dir_type(const char *digest,
+ authority_type_t type);
+#define router_digest_is_trusted_dir(d) \
+ router_digest_is_trusted_dir_type((d), 0)
routerlist_t *router_get_routerlist(void);
void routerlist_reset_warnings(void);
void routerlist_free(routerlist_t *routerlist);
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 8082bc5f5..7c3f27a80 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -990,10 +990,13 @@ router_pick_directory_server_impl(int requireother, int fascistfirewall,
continue;
if (requireother && router_digest_is_me(status->identity_digest))
continue;
+ if (type & V3_AUTHORITY) {
+ if (!(status->version_supports_v3_dir ||
+ router_digest_is_trusted_dir_type(status->identity_digest,
+ V3_AUTHORITY)))
+ continue;
+ }
is_trusted = router_digest_is_trusted_dir(status->identity_digest);
- if ((type & V3_AUTHORITY &&
- !(status->version_supports_v3_dir || is_trusted)))
- continue; /* is_trusted is not quite right XXXX020. */
if ((type & V2_AUTHORITY) && !(status->is_v2_dir || is_trusted))
continue;
if ((type & EXTRAINFO_CACHE) &&
@@ -1886,17 +1889,20 @@ router_digest_version_as_new_as(const char *digest, const char *cutoff)
return tor_version_as_new_as(router->platform, cutoff);
}
-/** Return true iff <b>digest</b> is the digest of the identity key of
- * a trusted directory. */
+/** Return true iff <b>digest</b> is the digest of the identity key of a
+ * trusted directory matching at least one bit of <b>type</b>. If <b>type</b>
+ * is zero, any authority is okay. */
int
-router_digest_is_trusted_dir(const char *digest)
+router_digest_is_trusted_dir_type(const char *digest, authority_type_t type)
{
if (!trusted_dir_servers)
return 0;
if (authdir_mode(get_options()) && router_digest_is_me(digest))
return 1;
SMARTLIST_FOREACH(trusted_dir_servers, trusted_dir_server_t *, ent,
- if (!memcmp(digest, ent->digest, DIGEST_LEN)) return 1);
+ if (!memcmp(digest, ent->digest, DIGEST_LEN)) {
+ return (!type) || ((type & ent->type) != 0);
+ });
return 0;
}