[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Implement new directory logic: download by descriptor diges...



Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv28626/src/or

Modified Files:
	directory.c or.h routerlist.c 
Log Message:
Implement new directory logic: download by descriptor digest, not by key digest. Caches try to download all listed digests from authorities; clients try to download "best" digests from caches.

Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.330
retrieving revision 1.331
diff -u -p -d -r1.330 -r1.331
--- directory.c	18 Dec 2005 22:34:24 -0000	1.330
+++ directory.c	27 Dec 2005 05:26:03 -0000	1.331
@@ -1034,9 +1034,9 @@ connection_dir_client_reached_eof(connec
     info(LD_DIR,"Received server info (size %d) from server '%s:%d'",
          (int)body_len, conn->address, conn->port);
     if (conn->requested_resource &&
-        !strcmpstart(conn->requested_resource,"fp/")) {
+        !strcmpstart(conn->requested_resource,"d/")) {
       which = smartlist_create();
-      dir_split_resource_into_fingerprints(conn->requested_resource+3,
+      dir_split_resource_into_fingerprints(conn->requested_resource+2,
                                            which, NULL, 0);
       n_asked_for = smartlist_len(which);
     }

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.765
retrieving revision 1.766
diff -u -p -d -r1.765 -r1.766
--- or.h	24 Dec 2005 22:48:12 -0000	1.765
+++ or.h	27 Dec 2005 05:26:03 -0000	1.766
@@ -759,7 +759,6 @@ typedef struct signed_descriptor_t {
 /** Information about another onion router in the network. */
 typedef struct {
   signed_descriptor_t cache_info;
-
   char *address; /**< Location of OR: either a hostname or an IP address. */
   char *nickname; /**< Human-readable OR name. */
 
@@ -797,12 +796,6 @@ typedef struct {
                             * us? */
   unsigned int is_fast:1; /** Do we think this is a fast OR? */
   unsigned int is_stable:1; /** Do we think this is a stable OR? */
-  unsigned int xx_is_recognized:1; /**< Temporary: do we think that this
-                                    * descriptor's digest is recognized?
-                                    */
-  unsigned int xx_is_extra_new:1; /**< Temporary: do we think that this
-                                   * descriptor's digest is recognized?
-                                   */
 
   /* The below items are used only by authdirservers for
    * reachability testing. */
@@ -838,15 +831,25 @@ typedef struct routerstatus_t {
                              * information with v2 of the directory
                              * protocol. (All directory caches cache v1
                              * directories.)  */
+
+  /** True if we, as a directory mirror, want to download the corresponding
+   * routerinfo from the authority who gave us this routerstatus.  (That is,
+   * if we don't have the routerinfo, and if we haven't already tried to get it
+   * from this authority.)
+   */
+  unsigned int need_to_mirror:1;
 } routerstatus_t;
 
-/** DOCDOC */
+/** Our "local" or combined view of the info from all networkstatus objects
+ * about a single router. */
 typedef struct local_routerstatus_t {
+  /** What do we believe to be the case about this router?  In this field,
+   * descriptor_digest represnets the descriptor we would most like to use for
+   * this router. */
   routerstatus_t status;
   time_t next_attempt_at; /**< When should we try this descriptor again? */
   uint8_t n_download_failures; /**< Number of failures trying to download the
                                 * most recent descriptor. */
-  unsigned int should_download:1; /**< DOCDOC */
   unsigned int name_lookup_warned:1; /**< Have we warned the user for referring
                                       * to this (unnamed) router by nickname?
                                       */
@@ -2302,8 +2305,7 @@ void update_networkstatus_downloads(time
 void update_router_descriptor_downloads(time_t now);
 void routers_update_all_from_networkstatus(void);
 void routers_update_status_from_networkstatus(smartlist_t *routers,
-                                              int reset_failures,
-                                              int assume_recognized);
+                                              int reset_failures);
 smartlist_t *router_list_superseded(void);
 int router_have_minimum_dir_info(void);
 void networkstatus_list_update_recent(time_t now);

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.403
retrieving revision 1.404
diff -u -p -d -r1.403 -r1.404
--- routerlist.c	18 Dec 2005 22:45:27 -0000	1.403
+++ routerlist.c	27 Dec 2005 05:26:03 -0000	1.404
@@ -31,8 +31,7 @@ static void local_routerstatus_free(loca
 static void trusted_dir_server_free(trusted_dir_server_t *ds);
 static void update_networkstatus_cache_downloads(time_t now);
 static void update_networkstatus_client_downloads(time_t now);
-static int routerdesc_digest_is_recognized(const char *identity,
-                                           const char *digest);
+static int signed_desc_digest_is_recognized(signed_descriptor_t *desc);
 static void routerlist_assert_ok(routerlist_t *rl);
 
 #define MAX_DESCRIPTORS_PER_ROUTER 5
@@ -1089,6 +1088,7 @@ routerinfo_free(routerinfo_t *router)
   tor_free(router);
[...981 lines suppressed...]
+    update_router_descriptor_client_downloads(now);
+  }
+}
+
 /** Return true iff we have enough networkstatus and router information to
  * start building circuits.  Right now, this means "at least 2 networkstatus
  * documents, and at least 1/4 of expected routers." */
@@ -3366,6 +3533,12 @@ router_reset_descriptor_download_failure
     rs->n_download_failures = 0;
     rs->next_attempt_at = 0;
   });
+  SMARTLIST_FOREACH(networkstatus_list, networkstatus_t *, ns,
+     SMARTLIST_FOREACH(ns->entries, routerstatus_t *, rs,
+       {
+         if (!router_get_by_descriptor_digest(rs->descriptor_digest))
+           rs->need_to_mirror = 1;
+       }));
   last_routerdesc_download_attempted = 0;
 }