Commit c1939246 authored by Roger Dingledine's avatar Roger Dingledine
Browse files

add a getinfo so vidalia can query our current bootstrap state, in case

it attaches partway through and wants to catch up.

matt, is this a good format for you, or is there an even better format?


svn:r15325
parent 3240cb3f
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -335,7 +335,7 @@ R - add an event to report geoip summaries to vidalia for bridge relays,
    so vidalia can say "recent activity (1-8 users) from sa".
R - investigate: it looks like if the bridge authority is unreachable,
    we're not falling back on querying bridges directly?
R - a getinfo so vidalia can query our current bootstrap state, in
R o a getinfo so vidalia can query our current bootstrap state, in
    case it attaches partway through and wants to catch up.
R - directory authorities shouldn't complain about bootstrapping problems
    just because they do a lot of reachability testing and some of
@@ -348,6 +348,8 @@ R - get matt to fix vidalia so it moves to a "starting tor" bootstrap
    state if it hasn't gotten any status events. Maybe it can even be
    more certain by checking the version (<0211) and/or looking at the
    results of the getinfo.
R - in circuituse.c,
    /* XXX021 consider setting n_conn->socket_error to TIMEOUT */

For 0.2.1.x:
  - Proposals to do:
+10 −0
Original line number Diff line number Diff line
@@ -214,3 +214,13 @@ Status: Open
  help texts and the controller can send the user to the right anchor in a
  "bootstrapping problems" help page?

6. Getting up to speed when the controller connects.

  There's a new "GETINFO /status/bootstrap-phase" option, which returns
  the most recent bootstrap phase status event sent. Specifically,
  it returns a string starting with either "NOTICE BOOTSTRAP ..." or
  "WARN BOOTSTRAP ...".

  Controllers should use this getinfo when they connect or attach to
  Tor to learn its current state.
+23 −2
Original line number Diff line number Diff line
@@ -76,6 +76,13 @@ static int disable_log_messages = 0;
static int authentication_cookie_is_set = 0;
static char authentication_cookie[AUTHENTICATION_COOKIE_LEN];

/** A sufficiently large size to record the last bootstrap phase string. */
#define BOOTSTRAP_MSG_LEN 1024

/** What was the last bootstrap phase message we sent? We keep track
 * of this so we can respond to getinfo status/bootstrap-phase queries. */
static char last_sent_bootstrap_message[BOOTSTRAP_MSG_LEN];

#define SHORT_NAMES 1
#define LONG_NAMES 2
#define ALL_NAMES (SHORT_NAMES|LONG_NAMES)
@@ -1765,6 +1772,8 @@ getinfo_helper_events(control_connection_t *control_conn,
      tor_snprintf(*answer, 16, "OR=%d DIR=%d",
                   check_whether_orport_reachable() ? 1 : 0,
                   check_whether_dirport_reachable() ? 1 : 0);
    } else if (!strcmp(question, "status/bootstrap-phase")) {
      *answer = tor_strdup(last_sent_bootstrap_message);
    } else if (!strcmpstart(question, "status/version/")) {
      int is_server = server_mode(get_options());
      networkstatus_t *c = networkstatus_get_latest_consensus();
@@ -1900,6 +1909,8 @@ static const getinfo_item_t getinfo_items[] = {
  DOC("status/enough-dir-info",
      "Whether we have enough up-to-date directory information to build "
      "circuits."),
  DOC("status/bootstrap-phase",
      "The last bootstrap phase status event that Tor sent."),
  DOC("status/version/recommended", "List of currently recommended versions."),
  DOC("status/version/current", "Status of the current version."),
  DOC("status/version/num-versioning", "Number of versioning authorities."),
@@ -3794,6 +3805,7 @@ void
control_event_bootstrap(bootstrap_status_t status, int progress)
{
  const char *tag, *summary;
  char buf[BOOTSTRAP_MSG_LEN];

  if (bootstrap_percent == 100)
    return; /* already bootstrapped; nothing to be done here. */
@@ -3813,9 +3825,13 @@ control_event_bootstrap(bootstrap_status_t status, int progress)
    bootstrap_status_to_string(status, &tag, &summary);
    log_notice(LD_CONTROL, "Bootstrapped %d%%: %s.",
               progress ? progress : status, summary);
    control_event_client_status(LOG_NOTICE,
    tor_snprintf(buf, sizeof(buf),
        "BOOTSTRAP PROGRESS=%d TAG=%s SUMMARY=\"%s\"",
        progress ? progress : status, tag, summary);
    tor_snprintf(last_sent_bootstrap_message,
                 sizeof(last_sent_bootstrap_message),
                 "NOTICE %s", buf);
    control_event_client_status(LOG_NOTICE, "%s", buf);
    if (status > bootstrap_percent) {
      bootstrap_percent = status; /* new milestone reached */
    }
@@ -3836,6 +3852,7 @@ control_event_bootstrap_problem(const char *warn, int reason)
{
  int status = bootstrap_percent;
  const char *tag, *summary;
  char buf[BOOTSTRAP_MSG_LEN];

  if (bootstrap_percent == 100)
    return; /* already bootstrapped; nothing to be done here. */
@@ -3849,9 +3866,13 @@ control_event_bootstrap_problem(const char *warn, int reason)
  log_warn(LD_CONTROL, "Problem bootstrapping. Stuck at %d%%: %s. (%s; %s)",
           status, summary, warn,
           orconn_end_reason_to_control_string(reason));
  control_event_client_status(LOG_WARN,
  tor_snprintf(buf, sizeof(buf),
      "BOOTSTRAP PROGRESS=%d TAG=%s SUMMARY=\"%s\" WARNING=\"%s\" REASON=%s",
      bootstrap_percent, tag, summary, warn,
      orconn_end_reason_to_control_string(reason));
  tor_snprintf(last_sent_bootstrap_message,
               sizeof(last_sent_bootstrap_message),
               "WARN %s", buf);
  control_event_client_status(LOG_WARN, "%s", buf);
}