summaryrefslogtreecommitdiff
path: root/src/or/control.c
diff options
context:
space:
mode:
authorSebastian Hahn <sebastian@torproject.org>2015-02-15 12:33:33 +0100
committerSebastian Hahn <sebastian@torproject.org>2015-02-15 12:36:07 +0100
commit0c11d8b2d218b48ede19601bb7400639e3883a9c (patch)
treebdf522a4681a6f58055422b58ab16bf70929ffbe /src/or/control.c
parent8feaf3846d67d80d6a1bae9867cdf55bafdc437e (diff)
downloadtor-0c11d8b2d218b48ede19601bb7400639e3883a9c.tar.gz
tor-0c11d8b2d218b48ede19601bb7400639e3883a9c.zip
Implement status/fresh-relay-descs command
The idea here is that a controller should be able to make Tor produce a new relay descriptor on demand, without that descriptor actually being uploaded to the dirauths (they would likely reject it anyway due to freshness concerns). Implements #14784.
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 064b745c9f..2977b8b90d 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."),