[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Implement status/fresh-relay-descs command



commit 0c11d8b2d218b48ede19601bb7400639e3883a9c
Author: Sebastian Hahn <sebastian@xxxxxxxxxxxxxx>
Date:   Sun Feb 15 12:33:33 2015 +0100

    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.
---
 changes/bug14784 |    4 ++++
 src/or/control.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)

diff --git a/changes/bug14784 b/changes/bug14784
new file mode 100644
index 0000000..1f50142
--- /dev/null
+++ b/changes/bug14784
@@ -0,0 +1,4 @@
+  o Minor features:
+    - Implement a new controller command "status/fresh-relay-descs" to
+      fetch a descriptor/extrainfo pair that was generated on demand
+      just for the controller's use. Implements ticket 14784.
diff --git a/src/or/control.c b/src/or/control.c
index 064b745..2977b8b 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."),



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits