mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
hs-v3: Implement HS_DESC UPLOAD event
Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
committed by
Nick Mathewson
parent
b71a9b60cc
commit
c7050eaa16
+12
-3
@@ -7286,17 +7286,26 @@ control_event_hs_descriptor_created(const char *onion_address,
|
||||
void
|
||||
control_event_hs_descriptor_upload(const char *onion_address,
|
||||
const char *id_digest,
|
||||
const char *desc_id)
|
||||
const char *desc_id,
|
||||
const char *hsdir_index)
|
||||
{
|
||||
char *hsdir_index_field = NULL;
|
||||
|
||||
if (BUG(!onion_address || !id_digest || !desc_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (hsdir_index) {
|
||||
tor_asprintf(&hsdir_index_field, " HSDIR_INDEX=%s", hsdir_index);
|
||||
}
|
||||
|
||||
send_control_event(EVENT_HS_DESC,
|
||||
"650 HS_DESC UPLOAD %s UNKNOWN %s %s\r\n",
|
||||
"650 HS_DESC UPLOAD %s UNKNOWN %s %s%s\r\n",
|
||||
onion_address,
|
||||
node_describe_longname_by_id(id_digest),
|
||||
desc_id);
|
||||
desc_id,
|
||||
hsdir_index_field ? hsdir_index_field : "");
|
||||
tor_free(hsdir_index_field);
|
||||
}
|
||||
|
||||
/** send HS_DESC event after got response from hs directory.
|
||||
|
||||
+2
-1
@@ -125,7 +125,8 @@ void control_event_hs_descriptor_created(const char *onion_address,
|
||||
int replica);
|
||||
void control_event_hs_descriptor_upload(const char *onion_address,
|
||||
const char *desc_id,
|
||||
const char *hs_dir);
|
||||
const char *hs_dir,
|
||||
const char *hsdir_index);
|
||||
void control_event_hs_descriptor_upload_end(const char *action,
|
||||
const char *onion_address,
|
||||
const char *hs_dir,
|
||||
|
||||
@@ -125,3 +125,32 @@ hs_control_desc_event_created(const char *onion_address,
|
||||
control_event_hs_descriptor_created(onion_address, base64_blinded_pk, -1);
|
||||
}
|
||||
|
||||
/* Send on the control port the "HS_DESC UPLOAD [...]" event.
|
||||
*
|
||||
* Using the onion address of the descriptor's service, the HSDir identity
|
||||
* digest, the blinded public key of the descriptor as a descriptor ID and the
|
||||
* HSDir index for this particular request. None can be NULL. */
|
||||
void
|
||||
hs_control_desc_event_upload(const char *onion_address,
|
||||
const char *hsdir_id_digest,
|
||||
const ed25519_public_key_t *blinded_pk,
|
||||
const uint8_t *hsdir_index)
|
||||
{
|
||||
char base64_blinded_pk[ED25519_BASE64_LEN + 1];
|
||||
|
||||
tor_assert(onion_address);
|
||||
tor_assert(hsdir_id_digest);
|
||||
tor_assert(blinded_pk);
|
||||
tor_assert(hsdir_index);
|
||||
|
||||
/* Build base64 encoded blinded key. */
|
||||
IF_BUG_ONCE(ed25519_public_to_base64(base64_blinded_pk, blinded_pk) < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
control_event_hs_descriptor_upload(onion_address, hsdir_id_digest,
|
||||
base64_blinded_pk,
|
||||
hex_str((const char *) hsdir_index,
|
||||
DIGEST256_LEN));
|
||||
}
|
||||
|
||||
|
||||
@@ -29,5 +29,11 @@ void hs_control_desc_event_received(const hs_ident_dir_conn_t *ident,
|
||||
void hs_control_desc_event_created(const char *onion_address,
|
||||
const ed25519_public_key_t *blinded_pk);
|
||||
|
||||
/* Event "HS_DESC UPLOAD [...]" */
|
||||
void hs_control_desc_event_upload(const char *onion_address,
|
||||
const char *hsdir_id_digest,
|
||||
const ed25519_public_key_t *blinded_pk,
|
||||
const uint8_t *hsdir_index);
|
||||
|
||||
#endif /* !defined(TOR_HS_CONTROL_H) */
|
||||
|
||||
|
||||
+4
-1
@@ -2267,9 +2267,12 @@ upload_descriptor_to_hsdir(const hs_service_t *service,
|
||||
desc->desc->plaintext_data.revision_counter,
|
||||
safe_str_client(node_describe(hsdir)),
|
||||
safe_str_client(hex_str((const char *) index, 32)));
|
||||
|
||||
/* Fire a UPLOAD control port event. */
|
||||
hs_control_desc_event_upload(service->onion_address, hsdir->identity,
|
||||
&desc->blinded_kp.pubkey, index);
|
||||
}
|
||||
|
||||
/* XXX: Inform control port of the upload event (#20699). */
|
||||
end:
|
||||
tor_free(encoded_desc);
|
||||
return;
|
||||
|
||||
@@ -3574,7 +3574,7 @@ directory_post_to_hs_dir(rend_service_descriptor_t *renddesc,
|
||||
"directories to post descriptors to.");
|
||||
control_event_hs_descriptor_upload(service_id,
|
||||
"UNKNOWN",
|
||||
"UNKNOWN");
|
||||
"UNKNOWN", NULL);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
@@ -3629,7 +3629,7 @@ directory_post_to_hs_dir(rend_service_descriptor_t *renddesc,
|
||||
hs_dir->or_port);
|
||||
control_event_hs_descriptor_upload(service_id,
|
||||
hs_dir->identity_digest,
|
||||
desc_id_base32);
|
||||
desc_id_base32, NULL);
|
||||
tor_free(hs_dir_ip);
|
||||
/* Remember successful upload to this router for next time. */
|
||||
if (!smartlist_contains_digest(successful_uploads,
|
||||
|
||||
Reference in New Issue
Block a user