summaryrefslogtreecommitdiff
path: root/src/or/control.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@ev0ke.net>2015-02-24 16:17:14 -0500
committerDavid Goulet <dgoulet@ev0ke.net>2015-04-21 14:15:02 -0400
commit7db58445fd00d5bbad72fd80497d20b7bc9a0297 (patch)
tree6cfb5f909e1ece90915ca9f10d3b869b2943df05 /src/or/control.c
parent084be23697e14b9ee26b3ac1eef2448af6368d10 (diff)
downloadtor-7db58445fd00d5bbad72fd80497d20b7bc9a0297.tar.gz
tor-7db58445fd00d5bbad72fd80497d20b7bc9a0297.zip
Control: add HS_DESC_CONTENT event
As defined in section 4.1.26 in the control-spec.txt, this new event replies the content of a successfully fetched HS descriptor. This also adds a unit test for the controller event. Signed-off-by: David Goulet <dgoulet@ev0ke.net>
Diffstat (limited to 'src/or/control.c')
-rw-r--r--src/or/control.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/or/control.c b/src/or/control.c
index 1bc833371d..e7d8b5cdef 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -943,6 +943,7 @@ static const struct control_event_t control_event_table[] = {
{ EVENT_CIRC_BANDWIDTH_USED, "CIRC_BW" },
{ EVENT_TRANSPORT_LAUNCHED, "TRANSPORT_LAUNCHED" },
{ EVENT_HS_DESC, "HS_DESC" },
+ { EVENT_HS_DESC_CONTENT, "HS_DESC_CONTENT" },
{ 0, NULL },
};
@@ -5414,6 +5415,36 @@ control_event_hs_descriptor_failed(const rend_data_t *rend_query,
id_digest, reason);
}
+/** send HS_DESC_CONTENT event after completion of a successful fetch from
+ * hs directory. */
+void
+control_event_hs_descriptor_content(const char *onion_address,
+ const char *desc_id,
+ const char *hsdir_id_digest,
+ const char *content)
+{
+ static const char *event_name = "HS_DESC_CONTENT";
+ char *esc_content = NULL;
+
+ if (!onion_address || !desc_id || !hsdir_id_digest || !content) {
+ log_warn(LD_BUG, "Called with onion_address==%p, desc_id==%p, "
+ "hsdir_id_digest==%p, content==%p", onion_address, desc_id,
+ hsdir_id_digest, content);
+ return;
+ }
+
+ write_escaped_data(content, strlen(content), &esc_content);
+
+ send_control_event(EVENT_HS_DESC_CONTENT, ALL_FORMATS,
+ "650 %s %s %s %s\r\n%s",
+ event_name,
+ onion_address,
+ desc_id,
+ node_describe_longname_by_id(hsdir_id_digest),
+ esc_content);
+ tor_free(esc_content);
+}
+
/** Free any leftover allocated memory of the control.c subsystem. */
void
control_free_all(void)