[tor-commits] [tor/master] Add onion address to the HS_DESC UPLOADED event

nickm at torproject.org nickm at torproject.org
Mon Feb 22 18:19:18 UTC 2016


commit 13a857183456307bf3e97aa8338219ca245b1040
Author: David Goulet <dgoulet at ev0ke.net>
Date:   Wed Feb 17 14:34:20 2016 -0500

    Add onion address to the HS_DESC UPLOADED event
    
    Fixes #16023
    
    Signed-off-by: David Goulet <dgoulet at ev0ke.net>
---
 changes/bug16023   |  4 ++++
 src/or/control.c   | 14 ++++++++++----
 src/or/control.h   |  5 ++++-
 src/or/directory.c |  7 ++++++-
 4 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/changes/bug16023 b/changes/bug16023
new file mode 100644
index 0000000..7451e27
--- /dev/null
+++ b/changes/bug16023
@@ -0,0 +1,4 @@
+  o Minor feature (hidden service, control port)
+    - Add the onion address to the HS_DESC event for the UPLOADED action
+      both on success or failure. It was previously hardcoded with UNKNOWN.
+      Fixes #16023;
diff --git a/src/or/control.c b/src/or/control.c
index 2c0209e..55b287d 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -6384,6 +6384,7 @@ control_event_hs_descriptor_receive_end(const char *action,
  */
 void
 control_event_hs_descriptor_upload_end(const char *action,
+                                       const char *onion_address,
                                        const char *id_digest,
                                        const char *reason)
 {
@@ -6400,8 +6401,9 @@ control_event_hs_descriptor_upload_end(const char *action,
   }
 
   send_control_event(EVENT_HS_DESC,
-                     "650 HS_DESC %s UNKNOWN UNKNOWN %s%s\r\n",
+                     "650 HS_DESC %s %s UNKNOWN %s%s\r\n",
                      action,
+                     rend_hsaddress_str_or_unknown(onion_address),
                      node_describe_longname_by_id(id_digest),
                      reason_field ? reason_field : "");
 
@@ -6431,14 +6433,17 @@ control_event_hs_descriptor_received(const char *onion_address,
  * called when we successfully uploaded a hidden service descriptor.
  */
 void
-control_event_hs_descriptor_uploaded(const char *id_digest)
+control_event_hs_descriptor_uploaded(const char *id_digest,
+                                     const char *onion_address)
 {
   if (!id_digest) {
     log_warn(LD_BUG, "Called with id_digest==%p",
              id_digest);
     return;
   }
-  control_event_hs_descriptor_upload_end("UPLOADED", id_digest, NULL);
+
+  control_event_hs_descriptor_upload_end("UPLOADED", onion_address,
+                                         id_digest, NULL);
 }
 
 /** Send HS_DESC event to inform controller that query <b>rend_query</b>
@@ -6500,6 +6505,7 @@ control_event_hs_descriptor_content(const char *onion_address,
  */
 void
 control_event_hs_descriptor_upload_failed(const char *id_digest,
+                                          const char *onion_address,
                                           const char *reason)
 {
   if (!id_digest) {
@@ -6507,7 +6513,7 @@ control_event_hs_descriptor_upload_failed(const char *id_digest,
              id_digest);
     return;
   }
-  control_event_hs_descriptor_upload_end("UPLOAD_FAILED",
+  control_event_hs_descriptor_upload_end("UPLOAD_FAILED", onion_address,
                                          id_digest, reason);
 }
 
diff --git a/src/or/control.h b/src/or/control.h
index 1f8e2bc..c5191f9 100644
--- a/src/or/control.h
+++ b/src/or/control.h
@@ -129,16 +129,19 @@ void control_event_hs_descriptor_receive_end(const char *action,
                                              const char *id_digest,
                                              const char *reason);
 void control_event_hs_descriptor_upload_end(const char *action,
+                                            const char *onion_address,
                                             const char *hs_dir,
                                             const char *reason);
 void control_event_hs_descriptor_received(const char *onion_address,
                                           const rend_data_t *rend_data,
                                           const char *id_digest);
-void control_event_hs_descriptor_uploaded(const char *hs_dir);
+void control_event_hs_descriptor_uploaded(const char *hs_dir,
+                                          const char *onion_address);
 void control_event_hs_descriptor_failed(const rend_data_t *rend_data,
                                         const char *id_digest,
                                         const char *reason);
 void control_event_hs_descriptor_upload_failed(const char *hs_dir,
+                                               const char *onion_address,
                                                const char *reason);
 void control_event_hs_descriptor_content(const char *onion_address,
                                          const char *desc_id,
diff --git a/src/or/directory.c b/src/or/directory.c
index ecf6da8..6c8b6a2 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -2364,16 +2364,21 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
   if (conn->base_.purpose == DIR_PURPOSE_UPLOAD_RENDDESC_V2) {
     #define SEND_HS_DESC_UPLOAD_FAILED_EVENT(reason) ( \
       control_event_hs_descriptor_upload_failed(conn->identity_digest, \
+                                                conn->rend_data->onion_address, \
                                                 reason) )
     log_info(LD_REND,"Uploaded rendezvous descriptor (status %d "
              "(%s))",
              status_code, escaped(reason));
+    /* Without the rend data, we'll have a problem identifying what has been
+     * uploaded for which service. */
+    tor_assert(conn->rend_data);
     switch (status_code) {
       case 200:
         log_info(LD_REND,
                  "Uploading rendezvous descriptor: finished with status "
                  "200 (%s)", escaped(reason));
-        control_event_hs_descriptor_uploaded(conn->identity_digest);
+        control_event_hs_descriptor_uploaded(conn->identity_digest,
+                                             conn->rend_data->onion_address);
         rend_service_desc_has_uploaded(conn->rend_data);
         break;
       case 400:





More information about the tor-commits mailing list