Commit 55520a2d authored by Nick Mathewson's avatar Nick Mathewson 🦀
Browse files

r15636@catbus: nickm | 2007-10-10 15:28:12 -0400

 Retry consensus and certificate downloads properly.  Do not fail when there are no certificates to download.  Do not download certificates we already have when retrying.


svn:r11841
parent f05685a8
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -13,6 +13,8 @@ Changes in version 0.2.0.8-alpha - 2007-10-12
    - Caches now download v3 network status documents as needed.
    - Caches now download descriptors listed in their v3 network status
      documents.
    - All hosts now attempt to download and keep fresh v3 authority
      certificates, and re-attempt after failures.

  o Minor features (router descriptor cache):
    - Store routers in a file called cached-descriptors instead of in
+6 −2
Original line number Diff line number Diff line
@@ -85,8 +85,12 @@ Things we'd like to do in 0.2.0.x:
        them
        o Download code
        o Code to schedule downloads
        - Code to retry failed downloads
        - Code to delay next download while fetching certificates
        o Code to retry failed downloads
        - Code to delay next download while fetching certificates to verify
          a consensus we already got.
        - Code to retry consensus download if we got one we already have.
        - Use if-modified-since on consensus download
        - Use if-modified-since on certificate download
        o Code to download routers listed in v3 networkstatus consensuses.
        - Enable for non-caches
      - Code to use v3 networkstatus documents once clients are
+1 −1
Original line number Diff line number Diff line
@@ -1411,7 +1411,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
           status_code, escaped(reason), conn->_base.address,
           conn->_base.port);
      tor_free(body); tor_free(headers); tor_free(reason);
      /* XXXX020NMNM retry. */
      networkstatus_consensus_download_failed(status_code);
      return -1;
    }
    log_info(LD_DIR,"Received consensus directory (size %d) from server "
+23 −14
Original line number Diff line number Diff line
@@ -45,12 +45,10 @@ static int networkstatus_list_has_changed = 0;
 * mirrors).  Clients don't use this now. */
static time_t last_networkstatus_download_attempted = 0;

/** The last time we tried to download a networkstatus, or 0 for "never".  We
 * use this to rate-limit download attempts for directory caches (including
 * mirrors).  Clients don't use this now. */
static time_t last_consensus_networkstatus_download_attempted = 0;
/**DOCDOC*/
static time_t time_to_download_next_consensus = 0;
/**DOCDOC*/
static download_status_t consensus_dl_status = { 0, 0};

/** List of strings for nicknames or fingerprints we've already warned about
 * and that are still conflicted. */ /*XXXX020 obsoleted by v3 dirs? */
@@ -644,7 +642,7 @@ routerstatus_get_by_hexdigest(const char *hexdigest)
 * network-statuses.
 */
static void
update_networkstatus_cache_downloads(time_t now)
update_v2_networkstatus_cache_downloads(time_t now)
{
  int authority = authdir_mode_v2(get_options());
  int interval =
@@ -706,7 +704,7 @@ update_networkstatus_cache_downloads(time_t now)
 * necessary".  See function comments for implementation details.
 */
static void
update_networkstatus_client_downloads(time_t now)
update_v2_networkstatus_client_downloads(time_t now)
{
  int n_live = 0, n_dirservers, n_running_dirservers, needed = 0;
  int fetch_latest = 0;
@@ -836,15 +834,21 @@ update_consensus_networkstatus_downloads(time_t now)
    return;
  if (authdir_mode_v3(options))
    return;
  if (!download_status_is_ready(&consensus_dl_status, now, 8))
    return; /*XXXX020 magic number 8.*/
  if (connection_get_by_type_purpose(CONN_TYPE_DIR,
                                     DIR_PURPOSE_FETCH_CONSENSUS))
    return;
  /* XXXX020 on failure, delay until next retry. */

  last_consensus_networkstatus_download_attempted = now;/*XXXX020 use this*/
  directory_get_from_dirserver(DIR_PURPOSE_FETCH_CONSENSUS,
                               ROUTER_PURPOSE_GENERAL, NULL, 1);
  // XXXX020 time_to_download_next_consensus = put it off for a while?
}

/** DOCDOC */
void
networkstatus_consensus_download_failed(int status_code)
{
  download_status_failed(&consensus_dl_status, status_code);
}

/** DOCDOC */
@@ -888,7 +892,8 @@ should_delay_dir_fetches(or_options_t *options)
  return 0;
}

/** Launch requests for networkstatus documents as appropriate. */
/** Launch requests for networkstatus documents and authority certificates as
 * appropriate. */
void
update_networkstatus_downloads(time_t now)
{
@@ -896,10 +901,14 @@ update_networkstatus_downloads(time_t now)
  if (should_delay_dir_fetches(options))
    return;
  if (dirserver_mode(options))
    update_networkstatus_cache_downloads(now);
    update_v2_networkstatus_cache_downloads(now);
  else
    update_networkstatus_client_downloads(now);
    update_v2_networkstatus_client_downloads(now);
  update_consensus_networkstatus_downloads(now);
  if (consensus_waiting_for_certs)
    authority_certs_fetch_missing(consensus_waiting_for_certs, now);
  else
    authority_certs_fetch_missing(current_consensus, now);
}

/** Return the network status with a given identity digest. */
@@ -978,7 +987,7 @@ networkstatus_set_current_consensus(const char *consensus, int from_cache,
                       options->DataDirectory);
          write_str_to_file(filename, consensus, 0);
        }
        authority_certs_fetch_missing(c);
        authority_certs_fetch_missing(c, now);
      }
      return 0;
    } else {
@@ -992,7 +1001,7 @@ networkstatus_set_current_consensus(const char *consensus, int from_cache,

  /* Are we missing any certificates at all? */
  if (r != 1)
    authority_certs_fetch_missing(c);
    authority_certs_fetch_missing(c, now);

  if (current_consensus)
    networkstatus_vote_free(current_consensus);
+3 −2
Original line number Diff line number Diff line
@@ -3043,10 +3043,11 @@ int tor_init(int argc, char **argv);

/********************************* networkstatus.c *********************/

/** How old do we allow a network-status to get before removing it
/** How old do we allow a v2 network-status to get before removing it
 * completely? */
#define MAX_NETWORKSTATUS_AGE (10*24*60*60)

void networkstatus_consensus_download_failed(int status_code);
void networkstatus_reset_warnings(void);
int router_reload_networkstatus(void);
/* for consensuses. */
@@ -3511,7 +3512,7 @@ authority_cert_t *authority_cert_get_newest_by_id(const char *id_digest);
authority_cert_t *authority_cert_get_by_sk_digest(const char *sk_digest);
authority_cert_t *authority_cert_get_by_digests(const char *id_digest,
                                                const char *sk_digest);
void authority_certs_fetch_missing(networkstatus_vote_t *status);
void authority_certs_fetch_missing(networkstatus_vote_t *status, time_t now);
void routerlist_add_family(smartlist_t *sl, routerinfo_t *router);
void add_nickname_list_to_smartlist(smartlist_t *sl, const char *list,
                                    int must_be_running);
Loading