[or-cvs] r11789: Make router_digest_is_trusted_dir able to check for type. Wh (in tor/trunk: . doc src/or)

nickm at seul.org nickm at seul.org
Mon Oct 8 17:44:21 UTC 2007


Author: nickm
Date: 2007-10-08 13:44:19 -0400 (Mon, 08 Oct 2007)
New Revision: 11789

Modified:
   tor/trunk/
   tor/trunk/doc/TODO
   tor/trunk/src/or/or.h
   tor/trunk/src/or/routerlist.c
Log:
 r14770 at 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.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r14770] on c95137ef-5f19-0410-b913-86e773d04f59

Modified: tor/trunk/doc/TODO
===================================================================
--- tor/trunk/doc/TODO	2007-10-08 17:44:09 UTC (rev 11788)
+++ tor/trunk/doc/TODO	2007-10-08 17:44:19 UTC (rev 11789)
@@ -83,8 +83,9 @@
         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

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2007-10-08 17:44:09 UTC (rev 11788)
+++ tor/trunk/src/or/or.h	2007-10-08 17:44:19 UTC (rev 11789)
@@ -3495,7 +3495,10 @@
 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);

Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2007-10-08 17:44:09 UTC (rev 11788)
+++ tor/trunk/src/or/routerlist.c	2007-10-08 17:44:19 UTC (rev 11789)
@@ -990,10 +990,13 @@
       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 @@
   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;
 }
 



More information about the tor-commits mailing list