diff options
author | Nick Mathewson <nickm@torproject.org> | 2006-03-15 05:06:56 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2006-03-15 05:06:56 +0000 |
commit | fb7b5545ce8a964e526b6f07806c53c76b5e0191 (patch) | |
tree | 3b8ee169c7c7ab96d5136067bb46c26824336b11 /src | |
parent | d0f24b1e46eff11a6f8f4a9373410d05ad6418dd (diff) | |
download | tor-fb7b5545ce8a964e526b6f07806c53c76b5e0191.tar.gz tor-fb7b5545ce8a964e526b6f07806c53c76b5e0191.zip |
Implement GETINFO(dir/server/foo); status will be harder.
svn:r6165
Diffstat (limited to 'src')
-rw-r--r-- | src/or/control.c | 21 | ||||
-rw-r--r-- | src/or/dirserv.c | 3 |
2 files changed, 24 insertions, 0 deletions
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, |