[or-cvs] r15325: add a getinfo so vidalia can query our current bootstrap sta (in tor/trunk: doc doc/spec/proposals src/or)

arma at seul.org arma at seul.org
Tue Jun 17 08:01:44 UTC 2008


Author: arma
Date: 2008-06-17 04:01:43 -0400 (Tue, 17 Jun 2008)
New Revision: 15325

Modified:
   tor/trunk/doc/TODO
   tor/trunk/doc/spec/proposals/137-bootstrap-phases.txt
   tor/trunk/src/or/control.c
Log:
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?


Modified: tor/trunk/doc/TODO
===================================================================
--- tor/trunk/doc/TODO	2008-06-17 07:39:21 UTC (rev 15324)
+++ tor/trunk/doc/TODO	2008-06-17 08:01:43 UTC (rev 15325)
@@ -335,7 +335,7 @@
     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 @@
     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:

Modified: tor/trunk/doc/spec/proposals/137-bootstrap-phases.txt
===================================================================
--- tor/trunk/doc/spec/proposals/137-bootstrap-phases.txt	2008-06-17 07:39:21 UTC (rev 15324)
+++ tor/trunk/doc/spec/proposals/137-bootstrap-phases.txt	2008-06-17 08:01:43 UTC (rev 15325)
@@ -214,3 +214,13 @@
   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.
+

Modified: tor/trunk/src/or/control.c
===================================================================
--- tor/trunk/src/or/control.c	2008-06-17 07:39:21 UTC (rev 15324)
+++ tor/trunk/src/or/control.c	2008-06-17 08:01:43 UTC (rev 15325)
@@ -76,6 +76,13 @@
 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 @@
       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 @@
   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 @@
 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 @@
     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 @@
 {
   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 @@
   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);
 }
 



More information about the tor-commits mailing list