summaryrefslogtreecommitdiff
path: root/src/or/directory.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@ev0ke.net>2015-03-11 14:52:28 -0400
committerDavid Goulet <dgoulet@ev0ke.net>2015-04-21 14:22:54 -0400
commit28cf9f2186a96bba74b0870b95a9fa1630305388 (patch)
tree6cb72af857cfeedb5ac200dece63581af4cb95be /src/or/directory.c
parent59f8dced114f20a147a5425ece67d7d44a81867b (diff)
downloadtor-28cf9f2186a96bba74b0870b95a9fa1630305388.tar.gz
tor-28cf9f2186a96bba74b0870b95a9fa1630305388.zip
Control: unbolt rend_data from HS desc event
The HS_DESC event was using rend_data_t from the dir connection to reply the onion address and authentication type. With the new HSFETCH command, it's now possible to fetch a descriptor only using the descriptor id thus resulting in not having an onion address in any HS_DESC event. This patch removes rend_query from the hs desc control functions and replace it by an onion address string and an auth type. On a successful fetch, the service id is taken from the fetched descriptor. For that, an extra parameter is added to "store as a client" function that contains the cache entry stored. This will make the control event functions scale more easily over time if other values not present in rend_data_t are needed since the rend_data from the dir connection might not contained everything we need. Signed-off-by: David Goulet <dgoulet@ev0ke.net>
Diffstat (limited to 'src/or/directory.c')
-rw-r--r--src/or/directory.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index b6b0a5d7e0..0e7b9542dc 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -2099,7 +2099,8 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
if (conn->base_.purpose == DIR_PURPOSE_FETCH_RENDDESC_V2) {
#define SEND_HS_DESC_FAILED_EVENT(reason) ( \
- control_event_hs_descriptor_failed(conn->rend_data, \
+ control_event_hs_descriptor_failed(conn->rend_data->onion_address, \
+ conn->rend_data->auth_type, \
conn->identity_digest, \
reason) )
#define SEND_HS_DESC_FAILED_CONTENT() ( \
@@ -2113,8 +2114,12 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
(int)body_len, status_code, escaped(reason));
switch (status_code) {
case 200:
+ {
+ rend_cache_entry_t *entry = NULL;
+
switch (rend_cache_store_v2_desc_as_client(body,
- conn->requested_resource, conn->rend_data)) {
+ conn->requested_resource, conn->rend_data,
+ &entry)) {
case RCS_BADDESC:
case RCS_NOTDIR: /* Impossible */
log_warn(LD_REND,"Fetching v2 rendezvous descriptor failed. "
@@ -2126,20 +2131,29 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
break;
case RCS_OKAY:
default:
+ {
+ char service_id[REND_SERVICE_ID_LEN_BASE32 + 1];
+ /* Should never be NULL here for an OKAY returned code. */
+ tor_assert(entry);
+ rend_get_service_id(entry->parsed->pk, service_id);
+
/* success. notify pending connections about this. */
log_info(LD_REND, "Successfully fetched v2 rendezvous "
"descriptor.");
- control_event_hs_descriptor_received(conn->rend_data,
+ control_event_hs_descriptor_received(service_id,
+ conn->rend_data->auth_type,
conn->identity_digest);
- control_event_hs_descriptor_content(conn->rend_data->onion_address,
+ control_event_hs_descriptor_content(service_id,
conn->requested_resource,
conn->identity_digest,
body);
conn->base_.purpose = DIR_PURPOSE_HAS_FETCHED_RENDDESC_V2;
- rend_client_desc_trynow(conn->rend_data->onion_address);
+ rend_client_desc_trynow(service_id);
break;
+ }
}
break;
+ }
case 404:
/* Not there. We'll retry when
* connection_about_to_close_connection() cleans this conn up. */