summaryrefslogtreecommitdiff
path: root/src/or/control.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2015-04-15 11:10:37 -0400
committerNick Mathewson <nickm@torproject.org>2015-04-15 11:10:37 -0400
commitb98cc79477e5eb70284bb70dc80d778d5d082cc1 (patch)
treefe000c70f1fb2bee5e9447a8da48d1e07d2392f0 /src/or/control.c
parentc3e8b7f2da7f5c7fc4d341b533b7031eab90a665 (diff)
parent0c11d8b2d218b48ede19601bb7400639e3883a9c (diff)
downloadtor-b98cc79477e5eb70284bb70dc80d778d5d082cc1.tar.gz
tor-b98cc79477e5eb70284bb70dc80d778d5d082cc1.zip
Merge remote-tracking branch 'sebastian/bug14784'
Diffstat (limited to 'src/or/control.c')
-rw-r--r--src/or/control.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/or/control.c b/src/or/control.c
index 5ec97bd9af..a34eb0d4c2 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -2100,6 +2100,47 @@ getinfo_helper_events(control_connection_t *control_conn,
return -1;
}
*answer = bridge_stats;
+ } else if (!strcmp(question, "status/fresh-relay-descs")) {
+ if (!server_mode(get_options())) {
+ *errmsg = "Only relays have descriptors";
+ return -1;
+ }
+ routerinfo_t *r;
+ extrainfo_t *e;
+ if (router_build_fresh_descriptor(&r, &e) < 0) {
+ *errmsg = "Error generating descriptor";
+ return -1;
+ }
+ size_t size = r->cache_info.signed_descriptor_len + 1;
+ if (e) {
+ size += e->cache_info.signed_descriptor_len + 1;
+ }
+ tor_assert(r->cache_info.signed_descriptor_len);
+ char *descs = tor_malloc(size);
+ char *cp = descs;
+ memcpy(cp, signed_descriptor_get_body(&r->cache_info),
+ r->cache_info.signed_descriptor_len);
+ cp += r->cache_info.signed_descriptor_len - 1;
+ if (e) {
+ if (cp[0] == '\0') {
+ cp[0] = '\n';
+ } else if (cp[0] != '\n') {
+ cp[1] = '\n';
+ cp++;
+ }
+ memcpy(cp, signed_descriptor_get_body(&e->cache_info),
+ e->cache_info.signed_descriptor_len);
+ cp += e->cache_info.signed_descriptor_len - 1;
+ }
+ if (cp[0] == '\n') {
+ cp[0] = '\0';
+ } else if (cp[0] != '\0') {
+ cp[1] = '\0';
+ }
+ log_warn(LD_CONFIG, "%s", descs);
+ *answer = descs;
+ routerinfo_free(r);
+ extrainfo_free(e);
} else {
return 0;
}
@@ -2210,6 +2251,8 @@ static const getinfo_item_t getinfo_items[] = {
"The last bootstrap phase status event that Tor sent."),
DOC("status/clients-seen",
"Breakdown of client countries seen by a bridge."),
+ DOC("status/fresh-relay-descs",
+ "A fresh relay/ei descriptor pair for Tor's current state. Not stored."),
DOC("status/version/recommended", "List of currently recommended versions."),
DOC("status/version/current", "Status of the current version."),
DOC("status/version/num-versioning", "Number of versioning authorities."),