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

[tor-commits] [tor/master] hs-v3: Implement HS_DESC_CONTENT event



commit 2c8e97db587df4c3145ab98dd9251290be7a3379
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date:   Tue Nov 14 11:06:35 2017 -0500

    hs-v3: Implement HS_DESC_CONTENT event
    
    Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
 src/or/directory.c  | 10 ++++++++++
 src/or/hs_control.c | 27 +++++++++++++++++++++++++++
 src/or/hs_control.h |  5 +++++
 3 files changed, 42 insertions(+)

diff --git a/src/or/directory.c b/src/or/directory.c
index ae8bf6eb0..1a7c016c3 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -3094,12 +3094,16 @@ handle_response_fetch_hsdesc_v3(dir_connection_t *conn,
       /* Fire control port FAILED event. */
       hs_control_desc_event_failed(conn->hs_ident, conn->identity_digest,
                                    "BAD_DESC");
+      hs_control_desc_event_content(conn->hs_ident, conn->identity_digest,
+                                    NULL);
     } else {
       log_info(LD_REND, "Stored hidden service descriptor successfully.");
       TO_CONN(conn)->purpose = DIR_PURPOSE_HAS_FETCHED_HSDESC;
       hs_client_desc_has_arrived(conn->hs_ident);
       /* Fire control port RECEIVED event. */
       hs_control_desc_event_received(conn->hs_ident, conn->identity_digest);
+      hs_control_desc_event_content(conn->hs_ident, conn->identity_digest,
+                                    body);
     }
     break;
   case 404:
@@ -3110,6 +3114,8 @@ handle_response_fetch_hsdesc_v3(dir_connection_t *conn,
     /* Fire control port FAILED event. */
     hs_control_desc_event_failed(conn->hs_ident, conn->identity_digest,
                                  "NOT_FOUND");
+    hs_control_desc_event_content(conn->hs_ident, conn->identity_digest,
+                                  NULL);
     break;
   case 400:
     log_warn(LD_REND, "Fetching v3 hidden service descriptor failed: "
@@ -3119,6 +3125,8 @@ handle_response_fetch_hsdesc_v3(dir_connection_t *conn,
     /* Fire control port FAILED event. */
     hs_control_desc_event_failed(conn->hs_ident, conn->identity_digest,
                                  "QUERY_REJECTED");
+    hs_control_desc_event_content(conn->hs_ident, conn->identity_digest,
+                                  NULL);
     break;
   default:
     log_warn(LD_REND, "Fetching v3 hidden service descriptor failed: "
@@ -3129,6 +3137,8 @@ handle_response_fetch_hsdesc_v3(dir_connection_t *conn,
     /* Fire control port FAILED event. */
     hs_control_desc_event_failed(conn->hs_ident, conn->identity_digest,
                                  "UNEXPECTED");
+    hs_control_desc_event_content(conn->hs_ident, conn->identity_digest,
+                                  NULL);
     break;
   }
 
diff --git a/src/or/hs_control.c b/src/or/hs_control.c
index fce6466ef..9a05d936b 100644
--- a/src/or/hs_control.c
+++ b/src/or/hs_control.c
@@ -172,3 +172,30 @@ hs_control_desc_event_uploaded(const hs_ident_dir_conn_t *ident,
   control_event_hs_descriptor_uploaded(hsdir_id_digest, onion_address);
 }
 
+/* Send on the control port the "HS_DESC_CONTENT [...]" event.
+ *
+ * Using the directory connection identifier, the HSDir identity digest and
+ * the body of the descriptor (as it was received from the directory). None
+ * can be NULL. */
+void
+hs_control_desc_event_content(const hs_ident_dir_conn_t *ident,
+                              const char *hsdir_id_digest,
+                              const char *body)
+{
+  char onion_address[HS_SERVICE_ADDR_LEN_BASE32 + 1];
+  char base64_blinded_pk[ED25519_BASE64_LEN + 1];
+
+  tor_assert(ident);
+  tor_assert(hsdir_id_digest);
+
+  /* Build onion address and encoded blinded key. */
+  IF_BUG_ONCE(ed25519_public_to_base64(base64_blinded_pk,
+                                       &ident->blinded_pk) < 0) {
+    return;
+  }
+  hs_build_address(&ident->identity_pk, HS_VERSION_THREE, onion_address);
+
+  control_event_hs_descriptor_content(onion_address, base64_blinded_pk,
+                                      hsdir_id_digest, body);
+}
+
diff --git a/src/or/hs_control.h b/src/or/hs_control.h
index de23dc73d..35062d4b8 100644
--- a/src/or/hs_control.h
+++ b/src/or/hs_control.h
@@ -39,5 +39,10 @@ void hs_control_desc_event_upload(const char *onion_address,
 void hs_control_desc_event_uploaded(const hs_ident_dir_conn_t *ident,
                                     const char *hsdir_id_digest);
 
+/* Event "HS_DESC_CONTENT [...]" */
+void hs_control_desc_event_content(const hs_ident_dir_conn_t *ident,
+                                   const char *hsdir_id_digest,
+                                   const char *body);
+
 #endif /* !defined(TOR_HS_CONTROL_H) */
 



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