diff options
author | David Goulet <dgoulet@ev0ke.net> | 2015-04-27 15:08:31 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-04-30 12:35:21 -0400 |
commit | 9a364026d314bfe76410318849e179dbd2e0b34d (patch) | |
tree | e4d0878e3475baf06a9ca23e7af8cda39b2c6226 /src/or/connection_edge.c | |
parent | e6a581f126bac80d1d0c61ae026d81076f03b77b (diff) | |
download | tor-9a364026d314bfe76410318849e179dbd2e0b34d.tar.gz tor-9a364026d314bfe76410318849e179dbd2e0b34d.zip |
Use rend_data_client/service_create() in code
Every callsite that use to allocate a rend_data_t object now use the
rend_data_client/service_create() function.
Signed-off-by: David Goulet <dgoulet@ev0ke.net>
Diffstat (limited to 'src/or/connection_edge.c')
-rw-r--r-- | src/or/connection_edge.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index 670905f136..4e1c7caec5 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -1499,12 +1499,27 @@ connection_ap_handshake_rewrite_and_attach(entry_connection_t *conn, return -1; } + /* Look up if we have client authorization configured for this hidden + * service. If we do, associate it with the rend_data. */ + rend_service_authorization_t *client_auth = + rend_client_lookup_service_authorization(socks->address); + + const char *cookie = NULL; + rend_auth_type_t auth_type = REND_NO_AUTH; + if (client_auth) { + log_info(LD_REND, "Using previously configured client authorization " + "for hidden service request."); + auth_type = client_auth->auth_type; + cookie = client_auth->descriptor_cookie; + } + /* Fill in the rend_data field so we can start doing a connection to * a hidden service. */ rend_data_t *rend_data = ENTRY_TO_EDGE_CONN(conn)->rend_data = - tor_malloc_zero(sizeof(rend_data_t)); - strlcpy(rend_data->onion_address, socks->address, - sizeof(rend_data->onion_address)); + rend_data_client_create(socks->address, NULL, cookie, auth_type); + if (rend_data == NULL) { + return -1; + } log_info(LD_REND,"Got a hidden service request for ID '%s'", safe_str_client(rend_data->onion_address)); @@ -1547,19 +1562,6 @@ connection_ap_handshake_rewrite_and_attach(entry_connection_t *conn, return 0; } - /* Look up if we have client authorization configured for this hidden - * service. If we do, associate it with the rend_data. */ - rend_service_authorization_t *client_auth = - rend_client_lookup_service_authorization( - rend_data->onion_address); - if (client_auth) { - log_info(LD_REND, "Using previously configured client authorization " - "for hidden service request."); - memcpy(rend_data->descriptor_cookie, - client_auth->descriptor_cookie, REND_DESC_COOKIE_LEN); - rend_data->auth_type = client_auth->auth_type; - } - /* We have the descriptor so launch a connection to the HS. */ base_conn->state = AP_CONN_STATE_CIRCUIT_WAIT; log_info(LD_REND, "Descriptor is here. Great."); |