mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
hs-v3: Implement HS_DESC RECEIVED event
Adds a v3 specific function to handle a received event. Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
committed by
Nick Mathewson
parent
8365de1da3
commit
3b436d495f
@@ -7398,6 +7398,29 @@ control_event_hsv2_descriptor_received(const char *onion_address,
|
||||
tor_free(desc_id_field);
|
||||
}
|
||||
|
||||
/* Send HS_DESC RECEIVED event
|
||||
*
|
||||
* Called when we successfully received a hidden service descriptor. */
|
||||
void
|
||||
control_event_hsv3_descriptor_received(const char *onion_address,
|
||||
const char *desc_id,
|
||||
const char *hsdir_id_digest)
|
||||
{
|
||||
char *desc_id_field = NULL;
|
||||
|
||||
if (BUG(!onion_address || !desc_id || !hsdir_id_digest)) {
|
||||
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("RECEIVED", onion_address, desc_id_field,
|
||||
REND_NO_AUTH, hsdir_id_digest, NULL);
|
||||
tor_free(desc_id_field);
|
||||
}
|
||||
|
||||
/** send HS_DESC UPLOADED event
|
||||
*
|
||||
* called when we successfully uploaded a hidden service descriptor.
|
||||
|
||||
@@ -144,6 +144,9 @@ void control_event_hsv3_descriptor_failed(const char *onion_address,
|
||||
const char *desc_id,
|
||||
const char *hsdir_id_digest,
|
||||
const char *reason);
|
||||
void control_event_hsv3_descriptor_received(const char *onion_address,
|
||||
const char *desc_id,
|
||||
const char *hsdir_id_digest);
|
||||
void control_event_hs_descriptor_upload_failed(const char *hs_dir,
|
||||
const char *onion_address,
|
||||
const char *reason);
|
||||
|
||||
@@ -3098,6 +3098,8 @@ handle_response_fetch_hsdesc_v3(dir_connection_t *conn,
|
||||
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);
|
||||
}
|
||||
break;
|
||||
case 404:
|
||||
|
||||
@@ -77,3 +77,28 @@ hs_control_desc_event_failed(const hs_ident_dir_conn_t *ident,
|
||||
hsdir_id_digest, reason);
|
||||
}
|
||||
|
||||
/* Send on the control port the "HS_DESC RECEIVED [...]" event.
|
||||
*
|
||||
* Using a directory connection identifier and the HSDir identity digest.
|
||||
* None can be NULL. */
|
||||
void
|
||||
hs_control_desc_event_received(const hs_ident_dir_conn_t *ident,
|
||||
const char *hsdir_id_digest)
|
||||
{
|
||||
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_hsv3_descriptor_received(onion_address, base64_blinded_pk,
|
||||
hsdir_id_digest);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,5 +21,9 @@ void hs_control_desc_event_failed(const hs_ident_dir_conn_t *ident,
|
||||
const char *hsdir_id_digest,
|
||||
const char *reason);
|
||||
|
||||
/* Event "HS_DESC RECEIVED [...]" */
|
||||
void hs_control_desc_event_received(const hs_ident_dir_conn_t *ident,
|
||||
const char *hsdir_id_digest);
|
||||
|
||||
#endif /* !defined(TOR_HS_CONTROL_H) */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user