summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2015-01-28 11:28:21 -0500
committerNick Mathewson <nickm@torproject.org>2015-01-28 11:28:21 -0500
commit32dad3b83bb21c4f1af4a8e45f539ab8cf8a6779 (patch)
tree2cf7d65d69e98c95dc3c1d475acd4c8bbdfb4c9f
parentc240eea0df38be9a82548a71fa54b553057a8b42 (diff)
downloadtor-32dad3b83bb21c4f1af4a8e45f539ab8cf8a6779.tar.gz
tor-32dad3b83bb21c4f1af4a8e45f539ab8cf8a6779.zip
Add GETINFO consensus/{valid-{after,until},fresh-until}
-rw-r--r--src/or/networkstatus.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index a25413a12f..9d6d5abe6a 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -1915,9 +1915,27 @@ getinfo_helper_networkstatus(control_connection_t *conn,
return *answer ? 0 : -1;
} else if (!strcmp(question, "consensus/packages")) {
const networkstatus_t *ns = networkstatus_get_latest_consensus();
- if (ns->package_lines)
+ if (ns && ns->package_lines)
*answer = smartlist_join_strings(ns->package_lines, "\n", 1, NULL);
return *answer ? 0 : -1;
+ } else if (!strcmp(question, "consensus/valid-after") ||
+ !strcmp(question, "consensus/fresh-until") ||
+ !strcmp(question, "consensus/valid-until")) {
+ const networkstatus_t *ns = networkstatus_get_latest_consensus();
+ if (ns) {
+ time_t t;
+ if (!strcmp(question, "consensus/valid-after"))
+ t = ns->valid_after;
+ else if (!strcmp(question, "consensus/fresh-until"))
+ t = ns->fresh_until;
+ else
+ t = ns->valid_until;
+
+ char tbuf[ISO_TIME_LEN+1];
+ format_iso_time(tbuf, t);
+ *answer = tor_strdup(tbuf);
+ }
+ return *answer ? 0 : -1;
} else {
return 0;
}