summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorRobert Ransom <rransom.8774@gmail.com>2011-11-07 15:32:33 -0800
committerRobert Ransom <rransom.8774@gmail.com>2011-11-07 15:32:33 -0800
commitef2b0bd528880ec7b1a56a79a988a1e92fbb1b15 (patch)
tree2d01466634cf97a0a3ab9151736406e074c44442 /src/or
parente26f5553ecf7563aeee7c203b36248f445f5d812 (diff)
downloadtor-ef2b0bd528880ec7b1a56a79a988a1e92fbb1b15.tar.gz
tor-ef2b0bd528880ec7b1a56a79a988a1e92fbb1b15.zip
Add GETINFO md/id/* and md/name/* items for relay microdescs
Diffstat (limited to 'src/or')
-rw-r--r--src/or/control.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/or/control.c b/src/or/control.c
index 1fdbac281c..52af4a0e60 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -1640,6 +1640,22 @@ getinfo_helper_dir(control_connection_t *control_conn,
*answer = smartlist_join_strings(sl, "", 0, NULL);
SMARTLIST_FOREACH(sl, char *, c, tor_free(c));
smartlist_free(sl);
+ } else if (!strcmpstart(question, "md/id/")) {
+ const node_t *node = node_get_by_hex_id(question+strlen("md/id/"));
+ const microdesc_t *md = NULL;
+ if (node) md = node->md;
+ if (md) {
+ tor_assert(md->body);
+ *answer = tor_strndup(md->body, md->bodylen);
+ }
+ } else if (!strcmpstart(question, "md/name/")) {
+ const node_t *node = node_get_by_nickname(question+strlen("md/name/"), 1);
+ const microdesc_t *md = NULL;
+ if (node) md = node->md;
+ if (md) {
+ tor_assert(md->body);
+ *answer = tor_strndup(md->body, md->bodylen);
+ }
} else if (!strcmpstart(question, "desc-annotations/id/")) {
ri = router_get_by_hexdigest(question+
strlen("desc-annotations/id/"));
@@ -2034,6 +2050,8 @@ static const getinfo_item_t getinfo_items[] = {
ITEM("desc/all-recent", dir,
"All non-expired, non-superseded router descriptors."),
ITEM("desc/all-recent-extrainfo-hack", dir, NULL), /* Hack. */
+ PREFIX("md/id/", dir, "Microdescriptors by ID"),
+ PREFIX("md/name/", dir, "Microdescriptors by name"),
PREFIX("extra-info/digest/", dir, "Extra-info documents by digest."),
PREFIX("net/listeners/", listeners, "Bound addresses by type"),
ITEM("ns/all", networkstatus,