hs-v3: Implement HS_DESC_CONTENT event

Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
David Goulet
2017-11-14 11:06:35 -05:00
committed by Nick Mathewson
parent cc26d4fa21
commit 2c8e97db58
3 changed files with 42 additions and 0 deletions
+10
View File
@@ -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;
}
+27
View File
@@ -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);
}
+5
View File
@@ -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) */