Browse Source

if we as a directory mirror don't know of any v1 directory
authorities, then don't try to cache any v1 directories.


svn:r6162

Roger Dingledine 19 years ago
parent
commit
903183ea28
3 changed files with 14 additions and 1 deletions
  1. 2 1
      src/or/main.c
  2. 1 0
      src/or/or.h
  3. 11 0
      src/or/routerlist.c

+ 2 - 1
src/or/main.c

@@ -826,7 +826,8 @@ run_scheduled_events(time_t now)
     if (options->DirPort && !options->V1AuthoritativeDir) {
     if (options->DirPort && !options->V1AuthoritativeDir) {
       /* XXX actually, we should only do this if we want to advertise
       /* XXX actually, we should only do this if we want to advertise
        * our dirport. not simply if we configured one. -RD */
        * our dirport. not simply if we configured one. -RD */
-      directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 1);
+      if (any_trusted_dir_supports_v1())
+        directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 1);
     }
     }
 
 
     time_to_fetch_directory = now + get_dir_fetch_period(options);
     time_to_fetch_directory = now + get_dir_fetch_period(options);

+ 1 - 0
src/or/or.h

@@ -2341,6 +2341,7 @@ void add_trusted_dir_server(const char *nickname,
                             const char *address, uint16_t port,
                             const char *address, uint16_t port,
                             const char *digest, int supports_v1);
                             const char *digest, int supports_v1);
 void clear_trusted_dir_servers(void);
 void clear_trusted_dir_servers(void);
+int any_trusted_dir_supports_v1(void);
 networkstatus_t *networkstatus_get_by_digest(const char *digest);
 networkstatus_t *networkstatus_get_by_digest(const char *digest);
 local_routerstatus_t *router_get_combined_status_by_digest(const char *digest);
 local_routerstatus_t *router_get_combined_status_by_digest(const char *digest);
 void update_networkstatus_downloads(time_t now);
 void update_networkstatus_downloads(time_t now);

+ 11 - 0
src/or/routerlist.c

@@ -2678,6 +2678,17 @@ clear_trusted_dir_servers(void)
   }
   }
 }
 }
 
 
+/** Return 1 if any trusted dir server supports v1 directories,
+ * else return 0. */
+int
+any_trusted_dir_supports_v1(void)
+{
+  if (trusted_dir_servers)
+    SMARTLIST_FOREACH(trusted_dir_servers, trusted_dir_server_t *, ent,
+                      if (ent->is_v1_authority) return 1);
+  return 0;
+}
+
 /** Return the network status with a given identity digest. */
 /** Return the network status with a given identity digest. */
 networkstatus_t *
 networkstatus_t *
 networkstatus_get_by_digest(const char *digest)
 networkstatus_get_by_digest(const char *digest)