]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add GETINFO md/id/* and md/name/* items for relay microdescs
authorRobert Ransom <rransom.8774@gmail.com>
Mon, 7 Nov 2011 23:32:33 +0000 (15:32 -0800)
committerRobert Ransom <rransom.8774@gmail.com>
Mon, 7 Nov 2011 23:32:33 +0000 (15:32 -0800)
changes/bug3832 [new file with mode: 0644]
src/or/control.c

diff --git a/changes/bug3832 b/changes/bug3832
new file mode 100644 (file)
index 0000000..230f0d7
--- /dev/null
@@ -0,0 +1,9 @@
+  o Major features:
+
+    - Allow Tor controllers like Vidalia to obtain the microdescriptor
+      for a relay by identity digest or nickname.  Previously,
+      microdescriptors were only available by their own digests, so a
+      controller would have to ask for and parse the whole
+      microdescriptor consensus in order to look up a single relay's
+      microdesc.  Fixes bug 3832; bugfix on 0.2.3.1-alpha.
+
index 1fdbac281c988ecc589f76e24af4575f55d06a2f..52af4a0e6056351f588d85cb3ab04a47144a0a69 100644 (file)
@@ -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,