[tor-commits] [tor/master] New "GETINFO dormant" to report whether Tor has gone idle

nickm at torproject.org nickm at torproject.org
Wed May 30 20:43:18 UTC 2012


commit 2418bc95946bd568e960f6ed42b0cd4dce3b835b
Author: Nick Mathewson <nickm at torproject.org>
Date:   Thu May 24 10:42:55 2012 -0400

    New "GETINFO dormant" to report whether Tor has gone idle
    
    Torbutton needs this; see bug 5954 and 4718.
---
 changes/bug5954  |    5 +++++
 src/or/control.c |    7 ++++++-
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/changes/bug5954 b/changes/bug5954
new file mode 100644
index 0000000..28c5a9c
--- /dev/null
+++ b/changes/bug5954
@@ -0,0 +1,5 @@
+  o Minor features (controller):
+    - Expose our view of whether we have gone dormant to the
+      controller, via a new "GETINFO dormant" value. Due to bug 4718,
+      torbutton needs this to avoid excessive version checking. Fixes
+      bug 5954.
diff --git a/src/or/control.c b/src/or/control.c
index d6e6932..57dd0f1 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -28,6 +28,7 @@
 #include "networkstatus.h"
 #include "policies.h"
 #include "reasons.h"
+#include "rephist.h"
 #include "router.h"
 #include "routerlist.h"
 #include "routerparse.h"
@@ -1408,6 +1409,9 @@ getinfo_helper_misc(control_connection_t *conn, const char *question,
     *answer = options_dump(get_options(), 1);
   } else if (!strcmp(question, "info/names")) {
     *answer = list_getinfo_options();
+  } else if (!strcmp(question, "dormant")) {
+    int dormant = rep_hist_circbuilding_dormant(time(NULL));
+    *answer = tor_strdup(dormant ? "1" : "0");
   } else if (!strcmp(question, "events/names")) {
     *answer = tor_strdup("CIRC STREAM ORCONN BW DEBUG INFO NOTICE WARN ERR "
                          "NEWDESC ADDRMAP AUTHDIR_NEWDESCS DESCCHANGED "
@@ -2007,12 +2011,13 @@ static const getinfo_item_t getinfo_items[] = {
          "Brief summary of router status by nickname (v2 directory format)."),
   PREFIX("ns/purpose/", networkstatus,
          "Brief summary of router status by purpose (v2 directory format)."),
-
   ITEM("network-status", dir,
        "Brief summary of router status (v1 directory format)"),
   ITEM("circuit-status", events, "List of current circuits originating here."),
   ITEM("stream-status", events,"List of current streams."),
   ITEM("orconn-status", events, "A list of current OR connections."),
+  ITEM("dormant", misc,
+       "Is Tor dormant (not building circuits because it's idle)?"),
   PREFIX("address-mappings/", events, NULL),
   DOC("address-mappings/all", "Current address mappings."),
   DOC("address-mappings/cache", "Current cached DNS replies."),





More information about the tor-commits mailing list