summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/control-spec.txt3
-rw-r--r--src/or/control.c21
-rw-r--r--src/or/dirserv.c3
3 files changed, 26 insertions, 1 deletions
diff --git a/doc/control-spec.txt b/doc/control-spec.txt
index 06e321e06a..7fb929575e 100644
--- a/doc/control-spec.txt
+++ b/doc/control-spec.txt
@@ -412,7 +412,8 @@ $Id$
contents, provided according to the specification for the URLs listed
in Section 4.4 of dir-spec.txt. Note that Tor MUST NOT provide
private information, such as descriptors for routers not marked as
- general-purpose.
+ general-purpose. When asked for 'authority' information for which this
+ Tor is not authoritative, Tor replies with an empty string.
Examples:
C: GETINFO version desc/name/moria1
diff --git a/src/or/control.c b/src/or/control.c
index 8f11e9c304..43970fc0e7 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -1455,6 +1455,27 @@ handle_getinfo_helper(const char *question, char **answer)
smartlist_free(mappings);
} else if (!strcmp(question, "dir-usage")) {
*answer = directory_dump_request_log();
+ } else if (!strcmpstart(question, "dir/server/")) {
+ size_t answer_len = 0, url_len = strlen(question)+2;
+ char *url = tor_malloc(url_len);
+ int res;
+ smartlist_t *descs = smartlist_create();
+ const char *msg;
+ char *cp;
+ tor_snprintf(url, url_len, "/tor/%s", question+4);
+ res = dirserv_get_routerdescs(descs, url, &msg);
+ SMARTLIST_FOREACH(descs, signed_descriptor_t *, sd,
+ answer_len += sd->signed_descriptor_len);
+ cp = *answer = tor_malloc(answer_len+1);
+ SMARTLIST_FOREACH(descs, signed_descriptor_t *, sd,
+ {
+ memcpy(cp, signed_descriptor_get_body(sd),
+ sd->signed_descriptor_len);
+ cp += sd->signed_descriptor_len;
+ });
+ *cp = '\0';
+ tor_free(url);
+ smartlist_free(descs);
}
return 0;
}
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 90bf2cde09..a78bfca7d7 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -1555,6 +1555,9 @@ dirserv_get_networkstatus_v2(smartlist_t *result,
* recognize the key (URL).
* If -1 is returned *<b>msg</b> will be set to an appropriate error
* message.
+ *
+ * (Despite its name, this function is also called from the controller, which
+ * exposes a similar means to fetch descriptors.)
*/
int
dirserv_get_routerdescs(smartlist_t *descs_out, const char *key,