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

[or-cvs] r10604: Refine r10571: more work on bridge stuff. - Only listen to r (tor/trunk/src/or)



Author: arma
Date: 2007-06-14 22:12:15 -0400 (Thu, 14 Jun 2007)
New Revision: 10604

Modified:
   tor/trunk/src/or/circuitbuild.c
   tor/trunk/src/or/circuituse.c
   tor/trunk/src/or/directory.c
   tor/trunk/src/or/main.c
   tor/trunk/src/or/or.h
   tor/trunk/src/or/routerlist.c
Log:
Refine r10571: more work on bridge stuff.
  - Only listen to responses for "authority" fetches if we're configured
    to use Bridges. Otherwise it's safe (and maybe smarter) to silently
    discard them like we used to.
  - React faster to download networkstatuses after the first bridge
    descriptor arrives.
  - Don't do dir fetches before we have any bridges, even when our 
    dirport is open.


Modified: tor/trunk/src/or/circuitbuild.c
===================================================================
--- tor/trunk/src/or/circuitbuild.c	2007-06-14 21:05:28 UTC (rev 10603)
+++ tor/trunk/src/or/circuitbuild.c	2007-06-15 02:12:15 UTC (rev 10604)
@@ -1728,11 +1728,7 @@
 {
   extend_info_t *info = tor_malloc_zero(sizeof(extend_info_t));
   memcpy(info->identity_digest, digest, DIGEST_LEN);
-  if (nickname)
-    strlcpy(info->nickname, nickname, sizeof(info->nickname));
-  else {
-    /* make one up */
-  }
+  strlcpy(info->nickname, nickname, sizeof(info->nickname));
   if (onion_key)
     info->onion_key = crypto_pk_dup_key(onion_key);
   info->addr = addr;
@@ -2751,9 +2747,12 @@
   tor_assert(ri);
   tor_assert(ri->purpose == ROUTER_PURPOSE_BRIDGE);
   if (get_options()->UseBridges) {
+    int first = !any_bridge_descriptors_known();
     ri->is_running = 1;
     add_an_entry_guard(ri);
     log_notice(LD_DIR, "new bridge descriptor '%s'", ri->nickname);
+    if (first)
+      routerlist_retry_directory_downloads(time(NULL));
   }
 }
 

Modified: tor/trunk/src/or/circuituse.c
===================================================================
--- tor/trunk/src/or/circuituse.c	2007-06-14 21:05:28 UTC (rev 10603)
+++ tor/trunk/src/or/circuituse.c	2007-06-15 02:12:15 UTC (rev 10604)
@@ -969,10 +969,7 @@
       log_notice(LD_APP|LD_DIR,
                  "Application request when we're believed to be "
                  "offline. Optimistically trying directory fetches again.");
-      router_reset_status_download_failures();
-      router_reset_descriptor_download_failures();
-      update_networkstatus_downloads(time(NULL));
-      update_router_descriptor_downloads(time(NULL));
+      routerlist_retry_directory_downloads(time(NULL));
     }
     /* the stream will be dealt with when router_have_minimum_dir_info becomes
      * 1, or when all directory attempts fail and directory_all_unreachable()

Modified: tor/trunk/src/or/directory.c
===================================================================
--- tor/trunk/src/or/directory.c	2007-06-14 21:05:28 UTC (rev 10603)
+++ tor/trunk/src/or/directory.c	2007-06-15 02:12:15 UTC (rev 10604)
@@ -1269,14 +1269,17 @@
       return dir_okay ? 0 : -1;
     }
     /* Learn the routers, assuming we requested by fingerprint or "all"
-     * or "authority". (We use "authority" to fetch our own descriptor for
-     * testing, and to fetch bridge descriptors for bootstrapping.)
-     */
-    /* XXX020 We now risk replacing ourself with a router running at
-     * the addr:port we think we have. Might want to check more carefully. */
+     * or "authority".
+     *
+     * We use "authority" to fetch our own descriptor for
+     * testing, and to fetch bridge descriptors for bootstrapping. Ignore
+     * the output of "authority" requests unless we are using bridges,
+     * since otherwise they'll be the response from reachability tests,
+     * and we don't really want to add that to our routerlist. */
     if (which || (conn->requested_resource &&
                   (!strcmpstart(conn->requested_resource, "all") ||
-                   !strcmpstart(conn->requested_resource, "authority")))) {
+                   (!strcmpstart(conn->requested_resource, "authority") &&
+                    get_options()->UseBridges)))) {
       /* as we learn from them, we remove them from 'which' */
       if (was_ei) {
         router_load_extrainfo_from_string(body, NULL, SAVED_NOWHERE, which);
@@ -1694,7 +1697,8 @@
                  "don't have a good one yet. Sending 503 Dir not available.");
       write_http_status_line(conn, 503, "Directory unavailable");
       /* try to get a new one now */
-      if (!already_fetching_directory(DIR_PURPOSE_FETCH_DIR))
+      if (!already_fetching_directory(DIR_PURPOSE_FETCH_DIR) &&
+          !should_delay_dir_fetches(options))
         directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 1);
       tor_free(url);
       return 0;
@@ -1744,7 +1748,8 @@
     if (!d) {
       write_http_status_line(conn, 503, "Directory unavailable");
       /* try to get a new one now */
-      if (!already_fetching_directory(DIR_PURPOSE_FETCH_RUNNING_LIST))
+      if (!already_fetching_directory(DIR_PURPOSE_FETCH_RUNNING_LIST) &&
+          !should_delay_dir_fetches(options))
         directory_get_from_dirserver(DIR_PURPOSE_FETCH_RUNNING_LIST, NULL, 1);
       tor_free(url);
       return 0;

Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c	2007-06-14 21:05:28 UTC (rev 10603)
+++ tor/trunk/src/or/main.c	2007-06-15 02:12:15 UTC (rev 10604)
@@ -937,7 +937,8 @@
     if (options->DirPort && !authdir_mode_v1(options)) {
       /* XXX020 actually, we should only do this if we want to advertise
        * our dirport. not simply if we configured one. -RD */
-      if (any_trusted_dir_is_v1_authority())
+      if (any_trusted_dir_is_v1_authority() &&
+          !should_delay_dir_fetches(options))
         directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 1);
     }
 /** How often do we (as a cache) fetch a new V1 directory? */
@@ -947,7 +948,7 @@
 
   /* Caches need to fetch running_routers; directory clients don't. */
   if (options->DirPort && time_to_fetch_running_routers < now) {
-    if (!authdir_mode_v1(options)) {
+    if (!authdir_mode_v1(options) && !should_delay_dir_fetches(options)) {
       directory_get_from_dirserver(DIR_PURPOSE_FETCH_RUNNING_LIST, NULL, 1);
     }
 /** How often do we (as a cache) fetch a new V1 runningrouters document? */
@@ -959,7 +960,7 @@
     rep_history_clean(now - options->RephistTrackTime);
     rend_cache_clean();
     /* XXX020 we only clean this stuff if DirPort is set?! -RD */
- }
+  }
 
   /* 2b. Once per minute, regenerate and upload the descriptor if the old
    * one is inaccurate. */

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2007-06-14 21:05:28 UTC (rev 10603)
+++ tor/trunk/src/or/or.h	2007-06-15 02:12:15 UTC (rev 10604)
@@ -3338,6 +3338,7 @@
 //routerstatus_t *routerstatus_get_by_hexdigest(const char *hexdigest);
 int should_delay_dir_fetches(or_options_t *options);
 void update_networkstatus_downloads(time_t now);
+void routerlist_retry_directory_downloads(time_t now);
 void update_router_descriptor_downloads(time_t now);
 void update_extrainfo_downloads(time_t now);
 void routers_update_all_from_networkstatus(time_t now);

Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2007-06-14 21:05:28 UTC (rev 10603)
+++ tor/trunk/src/or/routerlist.c	2007-06-15 02:12:15 UTC (rev 10604)
@@ -3545,6 +3545,17 @@
     update_networkstatus_client_downloads(now);
 }
 
+/** Clear all our timeouts for fetching v2 directory stuff, and then
+ * give it all a try again. */
+void
+routerlist_retry_directory_downloads(time_t now)
+{
+  router_reset_status_download_failures();
+  router_reset_descriptor_download_failures();
+  update_networkstatus_downloads(now);
+  update_router_descriptor_downloads(now);
+}
+
 /** Return 1 if all running sufficiently-stable routers will reject
  * addr:port, return 0 if any might accept it. */
 int