aboutsummaryrefslogtreecommitdiff
path: root/src/or/control.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-05-10 19:30:02 +0000
committerNick Mathewson <nickm@torproject.org>2007-05-10 19:30:02 +0000
commit11f3e894d3aa87276252e3376d03b46f252b06ad (patch)
tree80d8fa69d56148ed5ff122eae35198e2bb4a078d /src/or/control.c
parente3b2a7b53b1a92568f41dca426be451866e90c16 (diff)
downloadtor-11f3e894d3aa87276252e3376d03b46f252b06ad.tar
tor-11f3e894d3aa87276252e3376d03b46f252b06ad.tar.gz
r12708@catbus: nickm | 2007-05-10 15:18:08 -0400
Patch from shibz: implement a getinfo status/version/... so a controller can tell whether the current version is recommended, whether any versions are good, and how many authorities agree. svn:r10162
Diffstat (limited to 'src/or/control.c')
-rw-r--r--src/or/control.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/or/control.c b/src/or/control.c
index 3f8794316..4288d5658 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -1463,8 +1463,40 @@ getinfo_helper_events(control_connection_t *control_conn,
SMARTLIST_FOREACH(mappings, char *, cp, tor_free(cp));
smartlist_free(mappings);
} else if (!strcmpstart(question, "status/")) {
+ /* Note that status/ is not a catch-all for events; there's only supposed
+ * to be a status GETINFO if there's a corresponding STATUS event. */
if (!strcmp(question, "status/circuit-established")) {
*answer = tor_strdup(has_completed_circuit ? "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);
+ if (!strcmp(question, "status/version/recommended")) {
+ *answer = recommended;
+ return 0;
+ }
+ tor_free(recommended);
+ if (!strcmp(question, "status/version/current")) {
+ switch (st.consensus)
+ {
+ 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;
+ 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")) {
+ char s[33];
+ tor_snprintf(s, sizeof(s), "%d", st.n_concurring);
+ *answer = tor_strdup(s);
+ }
} else {
return 0;
}
@@ -1547,7 +1579,13 @@ static const getinfo_item_t getinfo_items[] = {
PREFIX("status/", events, NULL),
DOC("status/circuit-established",
"Whether we think client functionality is working."),
-
+ /* DOCDOC specify status/version/ */
+ 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."),
+ DOC("status/version/num-concurring",
+ "Number of versioning authorities agreeing on the status of the "
+ "current version"),
ITEM("address", misc, "IP address of this Tor host, if we can guess it."),
ITEM("dir-usage", misc, "Breakdown of bytes transferred over DirPort."),
PREFIX("dir/server/", dir,"Router descriptors as retrieved from a DirPort."),