summaryrefslogtreecommitdiff
path: root/src/or/control.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2017-11-10 14:01:33 -0500
committerNick Mathewson <nickm@torproject.org>2017-12-05 19:39:46 -0500
commit8365de1da3de53fc02d463d78187625d16a5180b (patch)
tree0d2698a5dcaed28de426024e40fcb7f07135c422 /src/or/control.c
parent743d0b9d91c0c26045aa9a725865870f0c052794 (diff)
downloadtor-8365de1da3de53fc02d463d78187625d16a5180b.tar.gz
tor-8365de1da3de53fc02d463d78187625d16a5180b.zip
hs-v3: Implement HS_DESC FAILED event
A new v3 specific function has been added named control_event_hsv3_descriptor_failed(). The HS v3 subsystem now uses it. Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/control.c')
-rw-r--r--src/or/control.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/or/control.c b/src/or/control.c
index cd1be5bf4d..3ba3a4b3a0 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -7296,6 +7296,7 @@ control_event_hs_descriptor_upload(const char *onion_address,
* NOTE: this is an internal function used by following functions:
* control_event_hsv2_descriptor_received
* control_event_hsv2_descriptor_failed
+ * control_event_hsv3_descriptor_failed
*
* So do not call this function directly.
*/
@@ -7447,6 +7448,32 @@ control_event_hsv2_descriptor_failed(const rend_data_t *rend_data,
tor_free(desc_id_field);
}
+/** Send HS_DESC event to inform controller that the query to
+ * <b>onion_address</b> failed to retrieve hidden service descriptor
+ * <b>desc_id</b> from directory identified by <b>hsdir_id_digest</b>. If
+ * NULL, "UNKNOWN" is used. If <b>reason</b> is not NULL, add it to REASON=
+ * field. */
+void
+control_event_hsv3_descriptor_failed(const char *onion_address,
+ const char *desc_id,
+ const char *hsdir_id_digest,
+ const char *reason)
+{
+ char *desc_id_field = NULL;
+
+ if (BUG(!onion_address || !desc_id || !reason)) {
+ return;
+ }
+
+ /* Because DescriptorID is an optional positional value, we need to add a
+ * whitespace before in order to not be next to the HsDir value. */
+ tor_asprintf(&desc_id_field, " %s", desc_id);
+
+ event_hs_descriptor_receive_end("FAILED", onion_address, desc_id_field,
+ REND_NO_AUTH, hsdir_id_digest, reason);
+ tor_free(desc_id_field);
+}
+
/** Send HS_DESC_CONTENT event after completion of a successful fetch from hs
* directory. If <b>hsdir_id_digest</b> is NULL, it is replaced by "UNKNOWN".
* If <b>content</b> is NULL, it is replaced by an empty string. The