summaryrefslogtreecommitdiff
path: root/src/or/control.c
diff options
context:
space:
mode:
authorrl1987 <rl1987@sdf.lonestar.org>2018-05-25 13:37:12 +0200
committerrl1987 <rl1987@sdf.lonestar.org>2018-06-08 13:25:25 +0300
commit25341245ae53a5800757fbfad37f5623b807befc (patch)
tree43d12c9b4dad934cc9c39a58181fe589810b4d96 /src/or/control.c
parent3716ddf1b42270b5db76f8b7b458c5f61aa40e23 (diff)
downloadtor-25341245ae53a5800757fbfad37f5623b807befc.tar.gz
tor-25341245ae53a5800757fbfad37f5623b807befc.zip
Implement GETINFO md/all
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 0d637dce7a..aba4bed0ee 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";