summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
Diffstat (limited to 'src/or')
-rw-r--r--src/or/control.c40
-rw-r--r--src/or/or.h12
-rw-r--r--src/or/routerlist.c14
3 files changed, 53 insertions, 13 deletions
diff --git a/src/or/control.c b/src/or/control.c
index 3f87943163..4288d56588 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."),
diff --git a/src/or/or.h b/src/or/or.h
index 0a80829481..318f4ed4a6 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -3193,6 +3193,18 @@ typedef enum version_status_t {
VS_UNRECOMMENDED=4 /**< This version is not recommended (general case) */
} version_status_t;
+typedef struct combined_version_status_t {
+ /** How many networkstatuses claim to know about versions? */
+ int n_versioning;
+ /** What do the majority of networkstatuses believe about this version? */
+ version_status_t consensus;
+ /** How many networkstatuses constitute the majority? */
+ int n_concurring;
+} combined_version_status_t;
+char *compute_recommended_versions(time_t now, int client,
+ const char *my_version,
+ combined_version_status_t *status_out);
+
int router_get_router_hash(const char *s, char *digest);
int router_get_dir_hash(const char *s, char *digest);
int router_get_runningrouters_hash(const char *s, char *digest);
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 5ce140528e..716fe7e360 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -3384,19 +3384,9 @@ networkstatus_get_by_digest(const char *digest)
* our server is broken, invalid, obsolete, etc. */
#define SELF_OPINION_INTERVAL (90*60)
-/** Result of checking whether a version is recommended. */
-typedef struct combined_version_status_t {
- /** How many networkstatuses claim to know about versions? */
- int n_versioning;
- /** What do the majority of networkstatuses believe about this version? */
- version_status_t consensus;
- /** How many networkstatuses constitute the majority? */
- int n_concurring;
-} combined_version_status_t;
-
-/** Return a string naming the versions of Tor recommended by
+/** Return a newly allocated string naming the versions of Tor recommended by
* more than half the versioning networkstatuses. */
-static char *
+char *
compute_recommended_versions(time_t now, int client,
const char *my_version,
combined_version_status_t *status_out)