]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Change directory_get_from_dirserver to take a set of flags to be passed to pick_...
authorNick Mathewson <nickm@torproject.org>
Thu, 11 Dec 2008 19:12:45 +0000 (19:12 +0000)
committerNick Mathewson <nickm@torproject.org>
Thu, 11 Dec 2008 19:12:45 +0000 (19:12 +0000)
svn:r17592

src/or/directory.c
src/or/networkstatus.c
src/or/or.h
src/or/rendclient.c
src/or/routerlist.c

index ee31cc6683405e36ddae85456ad3b3f02edf9291..fd609ea9a647a7cdbcc47f283ec134ecc1ff3c42 100644 (file)
@@ -290,19 +290,18 @@ directory_post_to_dirservers(uint8_t dir_purpose, uint8_t router_purpose,
 /** Start a connection to a random running directory server, using
  * connection purpose <b>dir_purpose</b>, intending to fetch descriptors
  * of purpose <b>router_purpose</b>, and requesting <b>resource</b>.
- * If <b>retry_if_no_servers</b>, then if all the possible servers seem
- * down, mark them up and try again.
+ * Use <b>pds_flags</b> as arguments to router_pick_directory_server
+ * or router_pick_trusteddirserver.
  */
 void
 directory_get_from_dirserver(uint8_t dir_purpose, uint8_t router_purpose,
-                             const char *resource, int retry_if_no_servers)
+                             const char *resource, int pds_flags)
 {
   routerstatus_t *rs = NULL;
   or_options_t *options = get_options();
   int prefer_authority = directory_fetches_from_authorities(options);
   int get_via_tor = purpose_needs_anonymity(dir_purpose, router_purpose);
   authority_type_t type;
-  int flags = retry_if_no_servers ? PDS_RETRY_IF_NO_SERVERS : 0;
   time_t if_modified_since = 0;
 
   /* FFFF we could break this switch into its own function, and call
@@ -368,15 +367,15 @@ directory_get_from_dirserver(uint8_t dir_purpose, uint8_t router_purpose,
     } else {
       if (prefer_authority || type == BRIDGE_AUTHORITY) {
         /* only ask authdirservers, and don't ask myself */
-        rs = router_pick_trusteddirserver(type, flags);
+        rs = router_pick_trusteddirserver(type, pds_flags);
       }
       if (!rs && type != BRIDGE_AUTHORITY) {
         /* anybody with a non-zero dirport will do */
-        rs = router_pick_directory_server(type, flags);
+        rs = router_pick_directory_server(type, pds_flags);
         if (!rs) {
           log_info(LD_DIR, "No router found for %s; falling back to "
                    "dirserver list.", dir_conn_purpose_to_string(dir_purpose));
-          rs = router_pick_trusteddirserver(type, flags);
+          rs = router_pick_trusteddirserver(type, pds_flags);
           if (!rs)
             get_via_tor = 1; /* last resort: try routing it via Tor */
         }
@@ -386,12 +385,12 @@ directory_get_from_dirserver(uint8_t dir_purpose, uint8_t router_purpose,
     /* Never use fascistfirewall; we're going via Tor. */
     if (dir_purpose == DIR_PURPOSE_FETCH_RENDDESC) {
       /* only ask hidserv authorities, any of them will do */
-      flags |= PDS_IGNORE_FASCISTFIREWALL|PDS_ALLOW_SELF;
-      rs = router_pick_trusteddirserver(HIDSERV_AUTHORITY, flags);
+      pds_flags |= PDS_IGNORE_FASCISTFIREWALL|PDS_ALLOW_SELF;
+      rs = router_pick_trusteddirserver(HIDSERV_AUTHORITY, pds_flags);
     } else {
       /* anybody with a non-zero dirport will do. Disregard firewalls. */
-      flags |= PDS_IGNORE_FASCISTFIREWALL;
-      rs = router_pick_directory_server(type, flags);
+      pds_flags |= PDS_IGNORE_FASCISTFIREWALL;
+      rs = router_pick_directory_server(type, pds_flags);
       /* If we have any hope of building an indirect conn, we know some router
        * descriptors.  If (rs==NULL), we can't build circuits anyway, so
        * there's no point in falling back to the authorities in this case. */
index 8ed66f068fe2c9aa9a9f768eacca560d0a9f504f..aaf7d7c29df76a65440431e8be1792cae55894d7 100644 (file)
@@ -1049,7 +1049,8 @@ update_v2_networkstatus_cache_downloads(time_t now)
     if (!connection_get_by_type_purpose(CONN_TYPE_DIR,
                                         DIR_PURPOSE_FETCH_NETWORKSTATUS))
       directory_get_from_dirserver(DIR_PURPOSE_FETCH_NETWORKSTATUS,
-                                   ROUTER_PURPOSE_GENERAL, "all.z",1);
+                                   ROUTER_PURPOSE_GENERAL, "all.z",
+                                   PDS_RETRY_IF_NO_SERVERS);
   }
 }
 
@@ -1092,7 +1093,8 @@ update_consensus_networkstatus_downloads(time_t now)
 
   log_info(LD_DIR, "Launching networkstatus consensus download.");
   directory_get_from_dirserver(DIR_PURPOSE_FETCH_CONSENSUS,
-                               ROUTER_PURPOSE_GENERAL, NULL, 1);
+                               ROUTER_PURPOSE_GENERAL, NULL,
+                               PDS_RETRY_IF_NO_SERVERS);
 }
 
 /** Called when an attempt to download a consensus fails: note that the
index 96af19e1f7d2320094b29affb159eb30fbc4cd13..0335afef48168301296b470772615fc1bc5472ea 100644 (file)
@@ -3220,7 +3220,7 @@ void directory_post_to_dirservers(uint8_t dir_purpose, uint8_t router_purpose,
                                   size_t payload_len, size_t extrainfo_len);
 void directory_get_from_dirserver(uint8_t dir_purpose, uint8_t router_purpose,
                                   const char *resource,
-                                  int retry_if_no_servers);
+                                  int pds_flags);
 void directory_get_from_all_authorities(uint8_t dir_purpose,
                                         uint8_t router_purpose,
                                         const char *resource);
index 3f0068cf74fe77651db3d932dbe16ab8f661547b..7964185fce146ebec18abea7d08622508a9b0ddb 100644 (file)
@@ -448,7 +448,8 @@ rend_client_refetch_renddesc(const char *query)
   } else {
     /* not one already; initiate a dir rend desc lookup */
     directory_get_from_dirserver(DIR_PURPOSE_FETCH_RENDDESC,
-                                 ROUTER_PURPOSE_GENERAL, query, 1);
+                                 ROUTER_PURPOSE_GENERAL, query,
+                                 PDS_RETRY_IF_NO_SERVERS);
   }
 }
 
index 5ed8813f9a0325d1af3de97dc800fd3ead37d196..032790cc6d3653e94c96be2d5cab7a9a045ebc32 100644 (file)
@@ -516,7 +516,7 @@ authority_certs_fetch_missing(networkstatus_t *status, time_t now)
     smartlist_free(fps);
   }
   directory_get_from_dirserver(DIR_PURPOSE_FETCH_CERTIFICATE, 0,
-                               resource, 1);
+                               resource, PDS_RETRY_IF_NO_SERVERS);
 
  done:
   tor_free(resource);
@@ -3807,7 +3807,8 @@ initiate_descriptor_downloads(routerstatus_t *source,
                                             0, /* not private */
                                             resource, NULL, 0, 0);
   } else {
-    directory_get_from_dirserver(purpose, ROUTER_PURPOSE_GENERAL, resource, 1);
+    directory_get_from_dirserver(purpose, ROUTER_PURPOSE_GENERAL, resource,
+                                 PDS_RETRY_IF_NO_SERVERS);
   }
   tor_free(resource);
 }
@@ -4193,7 +4194,8 @@ update_router_descriptor_downloads(time_t now)
       last_dummy_download + DUMMY_DOWNLOAD_INTERVAL < now) {
     last_dummy_download = now;
     directory_get_from_dirserver(DIR_PURPOSE_FETCH_SERVERDESC,
-                                 ROUTER_PURPOSE_GENERAL, "authority.z", 1);
+                                 ROUTER_PURPOSE_GENERAL, "authority.z",
+                                 PDS_RETRY_IF_NO_SERVERS);
   }
 }