diff options
author | David Goulet <dgoulet@torproject.org> | 2017-11-14 11:06:35 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-12-05 19:39:46 -0500 |
commit | 2c8e97db587df4c3145ab98dd9251290be7a3379 (patch) | |
tree | 0b3b6d2b20ff26091b4cafa3d927ad2daeade2da | |
parent | cc26d4fa2131e056dc7728335d877e0322611b12 (diff) | |
download | tor-2c8e97db587df4c3145ab98dd9251290be7a3379.tar.gz tor-2c8e97db587df4c3145ab98dd9251290be7a3379.zip |
hs-v3: Implement HS_DESC_CONTENT event
Signed-off-by: David Goulet <dgoulet@torproject.org>
-rw-r--r-- | src/or/directory.c | 10 | ||||
-rw-r--r-- | src/or/hs_control.c | 27 | ||||
-rw-r--r-- | src/or/hs_control.h | 5 |
3 files changed, 42 insertions, 0 deletions
diff --git a/src/or/directory.c b/src/or/directory.c index ae8bf6eb05..1a7c016c3e 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -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; } diff --git a/src/or/hs_control.c b/src/or/hs_control.c index fce6466ef1..9a05d936b6 100644 --- a/src/or/hs_control.c +++ b/src/or/hs_control.c @@ -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); +} + diff --git a/src/or/hs_control.h b/src/or/hs_control.h index de23dc73d8..35062d4b81 100644 --- a/src/or/hs_control.h +++ b/src/or/hs_control.h @@ -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) */ |