From 84d7677a8a4af82c9c68cada79ddecc13a628f66 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 8 Oct 2007 17:44:19 +0000 Subject: 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 --- doc/TODO | 3 ++- src/or/or.h | 5 ++++- src/or/routerlist.c | 20 +++++++++++++------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/doc/TODO b/doc/TODO index 8d21f8b3b..2105b3ae2 100644 --- a/doc/TODO +++ b/doc/TODO @@ -83,8 +83,9 @@ Things we'd like to do in 0.2.0.x: them o Download code o Code to schedule downloads - - Code to retry fail downloads + - Code to retry failed downloads - Code to delay next download while fetching certificates + - Code to download routers listed in v3 networkstatus consensuses. - Enable for non-caches - Code to use v3 networkstatus documents once clients are fetching them 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 digest is the digest of the identity key of - * a trusted directory. */ +/** Return true iff digest is the digest of the identity key of a + * trusted directory matching at least one bit of type. If type + * 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; } -- cgit v1.2.3