Commit 3ad6dc0e authored by Nick Mathewson's avatar Nick Mathewson 🦀
Browse files

r15806@catbus: nickm | 2007-10-15 19:14:57 -0400

 Implement v3 networkstatus client code.  Remove v2 networkstatus client code, except as needed for caches to fetch and serve v2 networkstatues and the routers they list.


svn:r11957
parent 95f6265a
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
Changes in version 0.2.0.9-alpha - 2007-10-??
  o Major features (v3 directory system):
    - Clients now download v3 consensus networkstatus documents instead
      of v2 networkstatus documents.  Clients and caches now their opinions
      about routers on these consensus documents.  Clients only download
      router descriptors listed in the consensus.

  o Major bugfixes:
    - Stop publishing a new server descriptor just because we HUP or
+23 −2
Original line number Diff line number Diff line
@@ -69,8 +69,29 @@ Things we'd like to do in 0.2.0.x:
        - Enable for non-caches
      - Code to use v3 networkstatus documents once clients are
        fetching them
        - Implement
        - Enable
        o Make everybody download v3 networkstatus docs.
        o Make clients not download v2 networkstatus docs.
        o Make everybody download routerdescs based on v3 networkstatus
          docs.
        o Change definition of "have enough information to build circuits"
        o Base version sanity check on v3 ns.
        o Change routerstatus_get_by_* to use v3 networkstatus docs.
        o Make download_status_get_by_descriptor_digest() use v2
          networkstatus docs too.
        o Eliminate routerstatus_list.
        o Make routers_update_all_from_networkstatus() [or equivalent]
          get called at the right time.
        o Make  routersstatus_list_update_from_consensus_networkstatus()
          get renamed and called.
        o When setting a new consensus, copy the extra fields out of the
          old consensus (if any).
        o Update named-server-map as appropriate.
        - Fix all XXXX020s.
        - Sort out need_to_mirror
        - Work hard to make sure clients never look at v2 networkstatus docs.
        - Check in old_routers before fetching a router status. You never
          know if we'll flap...

      - Controller support
        - GETINFO to get consensus
        - Event when new consensus arrives
+18 −13
Original line number Diff line number Diff line
@@ -1609,33 +1609,38 @@ getinfo_helper_events(control_connection_t *control_conn,
                   check_whether_orport_reachable() ? 1 : 0,
                   check_whether_dirport_reachable() ? 1 : 0);
    } else if (!strcmpstart(question, "status/version/")) {
      combined_version_status_t st;
      int is_server = server_mode(get_options());
      char *recommended;
      recommended = compute_recommended_versions(time(NULL),
                                                 !is_server, VERSION, &st);
      networkstatus_vote_t *c = networkstatus_get_latest_consensus();
      version_status_t status;
      const char *recommended;
      if (c) {
        recommended = is_server ? c->server_versions : c->client_versions;
        status = tor_version_is_obsolete(VERSION, recommended);
      } else {
        recommended = "?";
        status = VS_UNKNOWN;
      }

      if (!strcmp(question, "status/version/recommended")) {
        *answer = recommended;
        *answer = tor_strdup(recommended);
        return 0;
      }
      tor_free(recommended);
      if (!strcmp(question, "status/version/current")) {
        switch (st.consensus)
        switch (status)
          {
          case VS_RECOMMENDED: *answer = tor_strdup("recommended"); break;
          case VS_OLD: *answer = tor_strdup("obsolete"); break;
          case VS_NEW: *answer = tor_strdup("new"); break;
          case VS_NEW_IN_SERIES: *answer = tor_strdup("new in series"); break;
          case VS_UNRECOMMENDED: *answer = tor_strdup("unrecommended"); break;
          case VS_UNKNOWN: *answer = tor_strdup("unknown"); break;
          default: tor_fragile_assert();
          }
      } else if (!strcmp(question, "status/version/num-versioning")) {
        char s[33];
        tor_snprintf(s, sizeof(s), "%d", st.n_versioning);
        *answer = tor_strdup(s);
      } else if (!strcmp(question, "status/version/num-concurring")) {
      } else if (!strcmp(question, "status/version/num-versioning") ||
                 !strcmp(question, "status/version/num-concurring")) {
        /*XXXX020 deprecate.*/
        char s[33];
        tor_snprintf(s, sizeof(s), "%d", st.n_concurring);
        tor_snprintf(s, sizeof(s), "%d", get_n_authorities(V3_AUTHORITY));
        *answer = tor_strdup(s);
      }
    } else {
+6 −7
Original line number Diff line number Diff line
@@ -178,7 +178,7 @@ router_supports_extrainfo(const char *identity_digest, int is_authority)
      return 1;
  }
  if (is_authority) {
    routerstatus_t *rs = router_get_combined_status_by_digest(identity_digest);
    routerstatus_t *rs = router_get_consensus_status_by_id(identity_digest);
    if (rs && rs->version_supports_extrainfo_upload)
      return 1;
  }
@@ -1232,7 +1232,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
             "'%s:%d'. I'll try again soon.",
             status_code, escaped(reason), conn->_base.address,
             conn->_base.port);
    if ((rs = router_get_combined_status_by_digest(conn->identity_digest)))
    if ((rs = router_get_consensus_status_by_id(conn->identity_digest)))
      rs->last_dir_503_at = now;
    if ((ds = router_get_trusteddirserver_by_digest(conn->identity_digest)))
      ds->fake_status.last_dir_503_at = now;
@@ -1387,7 +1387,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
      if (next)
        next[1] = '\0';
      /* learn from it, and then remove it from 'which' */
      if (router_set_networkstatus(cp, now, source, which)<0)
      if (router_set_networkstatus_v2(cp, now, source, which)<0)
        break;
      if (next) {
        next[1] = 'n';
@@ -1426,6 +1426,8 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
      networkstatus_consensus_download_failed(0);
      return -1;
    }
    routers_update_all_from_networkstatus(now); /*launches router downloads*/
    directory_info_has_arrived(now, 0);
    log_info(LD_DIR, "Successfully loaded consensus.");
  }
  if (conn->_base.purpose == DIR_PURPOSE_FETCH_CERTIFICATE) {
@@ -2790,10 +2792,7 @@ dir_routerdesc_download_failed(smartlist_t *failed, int status_code,
      if (sd)
        dls = &sd->ei_dl_status;
    } else {
      routerstatus_t *rs =
        router_get_combined_status_by_descriptor_digest(digest);
      if (rs)
        dls = &rs->dl_status;
      dls = router_get_dl_status_by_descriptor_digest(digest);
    }
    if (!dls || dls->n_download_failures >= MAX_ROUTERDESC_DOWNLOAD_FAILURES)
      continue;
+4 −4
Original line number Diff line number Diff line
@@ -2380,12 +2380,12 @@ generate_networkstatus_opinion(int v2)
  }

  {
    networkstatus_t *ns;
    if (!(ns = networkstatus_parse_from_string(status))) {
    networkstatus_v2_t *ns;
    if (!(ns = networkstatus_v2_parse_from_string(status))) {
      log_err(LD_BUG,"Generated a networkstatus we couldn't parse.");
      goto done;
    }
    networkstatus_free(ns);
    networkstatus_v2_free(ns);
  }

  {
@@ -2395,7 +2395,7 @@ generate_networkstatus_opinion(int v2)
    *ns_ptr = new_cached_dir(status, now);
    status = NULL; /* So it doesn't get double-freed. */
    the_v2_networkstatus_is_dirty = 0;
    router_set_networkstatus((*ns_ptr)->dir, now, NS_GENERATED, NULL);
    router_set_networkstatus_v2((*ns_ptr)->dir, now, NS_GENERATED, NULL);
    r = *ns_ptr;
  }

Loading