Browse Source

hs-v3: Implement HS_DESC UPLOADED event

Signed-off-by: David Goulet <dgoulet@torproject.org>
David Goulet 6 years ago
parent
commit
427b247c8d
3 changed files with 23 additions and 1 deletions
  1. 1 1
      src/or/directory.c
  2. 18 0
      src/or/hs_control.c
  3. 4 0
      src/or/hs_control.h

+ 1 - 1
src/or/directory.c

@@ -3306,7 +3306,7 @@ handle_response_upload_hsdesc(dir_connection_t *conn,
   case 200:
     log_info(LD_REND, "Uploading hidden service descriptor: "
                       "finished with status 200 (%s)", escaped(reason));
-    /* XXX: Trigger control event. */
+    hs_control_desc_event_uploaded(conn->hs_ident, conn->identity_digest);
     break;
   case 400:
     log_fn(LOG_PROTOCOL_WARN, LD_REND,

+ 18 - 0
src/or/hs_control.c

@@ -154,3 +154,21 @@ hs_control_desc_event_upload(const char *onion_address,
                                              DIGEST256_LEN));
 }
 
+/* Send on the control port the "HS_DESC UPLOADED [...]" event.
+ *
+ * Using the directory connection identifier and the HSDir identity digest.
+ * None can be NULL. */
+void
+hs_control_desc_event_uploaded(const hs_ident_dir_conn_t *ident,
+                               const char *hsdir_id_digest)
+{
+  char onion_address[HS_SERVICE_ADDR_LEN_BASE32 + 1];
+
+  tor_assert(ident);
+  tor_assert(hsdir_id_digest);
+
+  hs_build_address(&ident->identity_pk, HS_VERSION_THREE, onion_address);
+
+  control_event_hs_descriptor_uploaded(hsdir_id_digest, onion_address);
+}
+

+ 4 - 0
src/or/hs_control.h

@@ -35,5 +35,9 @@ void hs_control_desc_event_upload(const char *onion_address,
                                   const ed25519_public_key_t *blinded_pk,
                                   const uint8_t *hsdir_index);
 
+/* Event "HS_DESC UPLOADED [...]" */
+void hs_control_desc_event_uploaded(const hs_ident_dir_conn_t *ident,
+                                    const char *hsdir_id_digest);
+
 #endif /* !defined(TOR_HS_CONTROL_H) */