浏览代码

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.

svn:r5659
Nick Mathewson 20 年之前
父节点
当前提交
ece9865020
共有 4 个文件被更改,包括 450 次插入278 次删除
  1. 23 20
      doc/TODO
  2. 2 2
      src/or/directory.c
  3. 13 11
      src/or/or.h
  4. 412 245
      src/or/routerlist.c

+ 23 - 20
doc/TODO

@@ -46,39 +46,42 @@ N - Destroy and truncated cells should have reasons.
     - Specify
     - Specify
     - Implement
     - Implement
 
 
-N - Only use a routerdesc if you recognize its hash.
+N . Only use a routerdesc if you recognize its hash.
     o (Must defer till dirservers are upgraded to latest code, which
     o (Must defer till dirservers are upgraded to latest code, which
       actually generates these hashes.)
       actually generates these hashes.)
-    - Of course, authdirservers must not do this.
+    . Of course, authdirservers must not do this.
     o If we have a routerdesc for Bob, and he says, "I'm 0.1.0.x", don't
     o If we have a routerdesc for Bob, and he says, "I'm 0.1.0.x", don't
       fetch a new one if it was published in the last 2 hours.
       fetch a new one if it was published in the last 2 hours.
-      - How does this interact with the 'recognized hash' rule?
-    - Do not ask for any routers until we have 2 networkstatuses.
-    - Client side:
-      - Keep a record of which hash is most desirable for each router inside
+      X Don't, actually. This is the authorities' job to straighten out.
+    o Do not ask for any routers until we have 2 networkstatuses.
+    . Client side:
+      o Keep a record of which hash is most desirable for each router inside
         local_routerstatus_t.
         local_routerstatus_t.
-        - If any hash is listed by two or more networkstatuses, the most
+        o If any hash is listed by two or more networkstatuses, the most
           recent such hash is most desirable.
           recent such hash is most desirable.
-        - Otherwise, the most recent is desirable.
-      - Once we've accepted a router, it's okay.
-      - Do not accept a router that no networkstatus lists. (This should maybe
+        o Otherwise, the most recent is desirable.
+      o Once we've accepted a router, it's okay.
+      o Do not accept a router that no networkstatus lists. (This should maybe
         get stricter.)
         get stricter.)
-      - Download by fingerprint.
-      - Reset failure count to zero when hash changes.
-    - Mirrors and authorities:
-      - Every time we hear a new networkstatus, we want every hash it lists.
-      - Make sure that we are always willing to keep at least N routerinfos
+      o Download by descriptor digest.
+      o Reset failure count to zero when hash changes.
+      . Test
+      - Do we want to rate-limit downloads of each identity?
+    . Mirrors and authorities:
+      o Every time we hear a new networkstatus, we want every hash it lists.
+      o Make sure that we are always willing to keep at least N routerinfos
         per router, where N = number of authorities.
         per router, where N = number of authorities.
-        - Do whatever else is needed to be sure that we don't request
+        o Do whatever else is needed to be sure that we don't request
           hashes that would be immediately discarded, or discard hashes
           hashes that would be immediately discarded, or discard hashes
           that would be immediately re-requested.
           that would be immediately re-requested.
-      - Only fetch routerinfo from an authority that mentions is.
-        - Only ask each authority once.
-        - Retry soon after failure.
-        - We need one bit per routerstatus for "should we download from
+      o Only fetch routerinfo from an authority that mentions is.
+        o Only ask each authority once.
+        o Retry soon after failure.
+        o We need one bit per routerstatus for "should we download from
           this guy."
           this guy."
       - Verify that we are actually storing retained old descriptors to our
       - Verify that we are actually storing retained old descriptors to our
         cache.
         cache.
+      - Test.
     - Non-directories don't need to keep descriptors in memory.
     - Non-directories don't need to keep descriptors in memory.
 
 
 N - Should router info have a pointer to routerstatus?
 N - Should router info have a pointer to routerstatus?

+ 2 - 2
src/or/directory.c

@@ -1034,9 +1034,9 @@ connection_dir_client_reached_eof(connection_t *conn)
     info(LD_DIR,"Received server info (size %d) from server '%s:%d'",
     info(LD_DIR,"Received server info (size %d) from server '%s:%d'",
          (int)body_len, conn->address, conn->port);
          (int)body_len, conn->address, conn->port);
     if (conn->requested_resource &&
     if (conn->requested_resource &&
-        !strcmpstart(conn->requested_resource,"fp/")) {
+        !strcmpstart(conn->requested_resource,"d/")) {
       which = smartlist_create();
       which = smartlist_create();
-      dir_split_resource_into_fingerprints(conn->requested_resource+3,
+      dir_split_resource_into_fingerprints(conn->requested_resource+2,
                                            which, NULL, 0);
                                            which, NULL, 0);
       n_asked_for = smartlist_len(which);
       n_asked_for = smartlist_len(which);
     }
     }

+ 13 - 11
src/or/or.h

@@ -759,7 +759,6 @@ typedef struct signed_descriptor_t {
 /** Information about another onion router in the network. */
 /** Information about another onion router in the network. */
 typedef struct {
 typedef struct {
   signed_descriptor_t cache_info;
   signed_descriptor_t cache_info;
-
   char *address; /**< Location of OR: either a hostname or an IP address. */
   char *address; /**< Location of OR: either a hostname or an IP address. */
   char *nickname; /**< Human-readable OR name. */
   char *nickname; /**< Human-readable OR name. */
 
 
@@ -797,12 +796,6 @@ typedef struct {
                             * us? */
                             * us? */
   unsigned int is_fast:1; /** Do we think this is a fast OR? */
   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 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
   /* The below items are used only by authdirservers for
    * reachability testing. */
    * reachability testing. */
@@ -838,15 +831,25 @@ typedef struct routerstatus_t {
                              * information with v2 of the directory
                              * information with v2 of the directory
                              * protocol. (All directory caches cache v1
                              * protocol. (All directory caches cache v1
                              * directories.)  */
                              * 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;
 } routerstatus_t;
 
 
-/** DOCDOC */
+/** Our "local" or combined view of the info from all networkstatus objects
+ * about a single router. */
 typedef struct local_routerstatus_t {
 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;
   routerstatus_t status;
   time_t next_attempt_at; /**< When should we try this descriptor again? */
   time_t next_attempt_at; /**< When should we try this descriptor again? */
   uint8_t n_download_failures; /**< Number of failures trying to download the
   uint8_t n_download_failures; /**< Number of failures trying to download the
                                 * most recent descriptor. */
                                 * most recent descriptor. */
-  unsigned int should_download:1; /**< DOCDOC */
   unsigned int name_lookup_warned:1; /**< Have we warned the user for referring
   unsigned int name_lookup_warned:1; /**< Have we warned the user for referring
                                       * to this (unnamed) router by nickname?
                                       * to this (unnamed) router by nickname?
                                       */
                                       */
@@ -2302,8 +2305,7 @@ void update_networkstatus_downloads(time_t now);
 void update_router_descriptor_downloads(time_t now);
 void update_router_descriptor_downloads(time_t now);
 void routers_update_all_from_networkstatus(void);
 void routers_update_all_from_networkstatus(void);
 void routers_update_status_from_networkstatus(smartlist_t *routers,
 void routers_update_status_from_networkstatus(smartlist_t *routers,
-                                              int reset_failures,
-                                              int assume_recognized);
+                                              int reset_failures);
 smartlist_t *router_list_superseded(void);
 smartlist_t *router_list_superseded(void);
 int router_have_minimum_dir_info(void);
 int router_have_minimum_dir_info(void);
 void networkstatus_list_update_recent(time_t now);
 void networkstatus_list_update_recent(time_t now);

文件差异内容过多而无法显示
+ 412 - 245
src/or/routerlist.c


部分文件因为文件数量过多而无法显示