summaryrefslogtreecommitdiff
path: root/src/or/control.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-06-17 20:20:15 -0400
committerNick Mathewson <nickm@torproject.org>2018-06-17 20:20:15 -0400
commit5746e210b8d0dfc54447ca31d6b2ac55a13271cc (patch)
treeeb5db92e99e6201f47acd9c5dd11e02608bcfd5b /src/or/control.c
parentd5e4b6983f88d6a31303008897e6f75e9a9777ff (diff)
parent25341245ae53a5800757fbfad37f5623b807befc (diff)
downloadtor-5746e210b8d0dfc54447ca31d6b2ac55a13271cc.tar.gz
tor-5746e210b8d0dfc54447ca31d6b2ac55a13271cc.zip
Merge remote-tracking branch 'rl1987/feature8323_squashed2'
Diffstat (limited to 'src/or/control.c')
-rw-r--r--src/or/control.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/or/control.c b/src/or/control.c
index 95b16cf5a8..72d4ff3189 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -2207,6 +2207,27 @@ getinfo_helper_dir(control_connection_t *control_conn,
return -1;
}
}
+ } else if (!strcmp(question, "md/all")) {
+ const smartlist_t *nodes = nodelist_get_list();
+ tor_assert(nodes);
+
+ if (smartlist_len(nodes) == 0) {
+ *answer = tor_strdup("");
+ return 0;
+ }
+
+ smartlist_t *microdescs = smartlist_new();
+
+ SMARTLIST_FOREACH_BEGIN(nodes, node_t *, n) {
+ if (n->md && n->md->body) {
+ char *copy = tor_strndup(n->md->body, n->md->bodylen);
+ smartlist_add(microdescs, copy);
+ }
+ } SMARTLIST_FOREACH_END(n);
+
+ *answer = smartlist_join_strings(microdescs, "", 0, NULL);
+ SMARTLIST_FOREACH(microdescs, char *, md, tor_free(md));
+ smartlist_free(microdescs);
} else if (!strcmpstart(question, "md/id/")) {
const node_t *node = node_get_by_hex_id(question+strlen("md/id/"), 0);
const microdesc_t *md = NULL;
@@ -3241,6 +3262,7 @@ static const getinfo_item_t getinfo_items[] = {
ITEM("desc/download-enabled", dir,
"Do we try to download router descriptors?"),
ITEM("desc/all-recent-extrainfo-hack", dir, NULL), /* Hack. */
+ ITEM("md/all", dir, "All known microdescriptors."),
PREFIX("md/id/", dir, "Microdescriptors by ID"),
PREFIX("md/name/", dir, "Microdescriptors by name"),
ITEM("md/download-enabled", dir,
@@ -3400,6 +3422,7 @@ handle_control_getinfo(control_connection_t *conn, uint32_t len,
SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
SMARTLIST_FOREACH_BEGIN(questions, const char *, q) {
const char *errmsg = NULL;
+
if (handle_getinfo_helper(conn, q, &ans, &errmsg) < 0) {
if (!errmsg)
errmsg = "Internal error";