Commit 3d641bde authored by Roger Dingledine's avatar Roger Dingledine
Browse files

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.


svn:r10604
parent 4398a099
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -1728,11 +1728,7 @@ extend_info_alloc(const char *nickname, const char *digest,
{
  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 */
  }
  if (onion_key)
    info->onion_key = crypto_pk_dup_key(onion_key);
  info->addr = addr;
@@ -2751,9 +2747,12 @@ learned_bridge_descriptor(routerinfo_t *ri)
  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));
  }
}

+1 −4
Original line number Diff line number Diff line
@@ -969,10 +969,7 @@ circuit_get_open_circ_or_launch(edge_connection_t *conn,
      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()
+13 −8
Original line number Diff line number Diff line
@@ -1269,14 +1269,17 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
      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 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
                 "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 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
    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;
+4 −3
Original line number Diff line number Diff line
@@ -937,7 +937,8 @@ run_scheduled_events(time_t now)
    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 @@ run_scheduled_events(time_t now)

  /* 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? */
+1 −0
Original line number Diff line number Diff line
@@ -3338,6 +3338,7 @@ local_routerstatus_t *router_get_combined_status_by_descriptor_digest(
//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);
Loading