Replace remaining directory_initiate_command_* instances

This commit is contained in:
Nick Mathewson 2017-04-21 15:08:28 -04:00
parent 4e393f5318
commit 8aadd60eac
6 changed files with 59 additions and 38 deletions

View File

@ -2527,7 +2527,7 @@ connection_ap_handshake_send_begin(entry_connection_t *ap_conn)
/* Sensitive directory connections must have an anonymous path length.
* Otherwise, directory connections are typically one-hop.
* This matches the earlier check for directory connection path anonymity
* in directory_initiate_command_rend(). */
* in directory_initiate_request(). */
if (purpose_needs_anonymity(linked_dir_conn_base->purpose,
TO_DIR_CONN(linked_dir_conn_base)->router_purpose,
TO_DIR_CONN(linked_dir_conn_base)->requested_resource)) {

View File

@ -5303,7 +5303,8 @@ typedef struct dir_server_t {
* address information from published? */
routerstatus_t fake_status; /**< Used when we need to pass this trusted
* dir_server_t to directory_initiate_command_*
* dir_server_t to
* directory_request_set_routerstatus.
* as a routerstatus_t. Not updated by the
* router-status management code!
**/

View File

@ -756,13 +756,15 @@ directory_get_from_hs_dir(const char *desc_id,
/* Send fetch request. (Pass query and possibly descriptor cookie so that
* they can be written to the directory connection and be referred to when
* the response arrives. */
directory_initiate_command_routerstatus_rend(hs_dir,
DIR_PURPOSE_FETCH_RENDDESC_V2,
ROUTER_PURPOSE_GENERAL,
how_to_fetch,
desc_id_base32,
NULL, 0, 0,
rend_query, NULL);
directory_request_t *req =
directory_request_new(DIR_PURPOSE_FETCH_RENDDESC_V2);
directory_request_set_routerstatus(req, hs_dir);
directory_request_set_indirection(req, how_to_fetch);
directory_request_set_resource(req, desc_id_base32);
directory_request_set_rend_query(req, rend_query);
directory_initiate_request(req);
directory_request_free(req);
log_info(LD_REND, "Sending fetch request for v2 descriptor for "
"service '%s' with descriptor ID '%s', auth type %d, "
"and descriptor cookie '%s' to hidden service "

View File

@ -3712,13 +3712,16 @@ directory_post_to_hs_dir(rend_service_descriptor_t *renddesc,
* request. Lookup is made in rend_service_desc_has_uploaded(). */
rend_data = rend_data_client_create(service_id, desc->desc_id, NULL,
REND_NO_AUTH);
directory_initiate_command_routerstatus_rend(hs_dir,
DIR_PURPOSE_UPLOAD_RENDDESC_V2,
ROUTER_PURPOSE_GENERAL,
DIRIND_ANONYMOUS, NULL,
desc->desc_str,
strlen(desc->desc_str),
0, rend_data, NULL);
directory_request_t *req =
directory_request_new(DIR_PURPOSE_UPLOAD_RENDDESC_V2);
directory_request_set_routerstatus(req, hs_dir);
directory_request_set_indirection(req, DIRIND_ANONYMOUS);
directory_request_set_payload(req,
desc->desc_str, strlen(desc->desc_str));
directory_request_set_rend_query(req, rend_data);
directory_initiate_request(req);
directory_request_free(req);
rend_data_free(rend_data);
base32_encode(desc_id_base32, sizeof(desc_id_base32),
desc->desc_id, DIGEST_LEN);

View File

@ -1470,13 +1470,23 @@ consider_testing_reachability(int test_or, int test_dir)
!connection_get_by_type_addr_port_purpose(
CONN_TYPE_DIR, &addr, me->dir_port,
DIR_PURPOSE_FETCH_SERVERDESC)) {
tor_addr_port_t my_orport, my_dirport;
memcpy(&my_orport.addr, &addr, sizeof(addr));
memcpy(&my_dirport.addr, &addr, sizeof(addr));
my_orport.port = me->or_port;
my_dirport.port = me->dir_port;
/* ask myself, via tor, for my server descriptor. */
directory_initiate_command(&addr, me->or_port,
&addr, me->dir_port,
me->cache_info.identity_digest,
DIR_PURPOSE_FETCH_SERVERDESC,
ROUTER_PURPOSE_GENERAL,
DIRIND_ANON_DIRPORT, "authority.z", NULL, 0, 0);
directory_request_t *req =
directory_request_new(DIR_PURPOSE_FETCH_SERVERDESC);
directory_request_set_or_addr_port(req, &my_orport);
directory_request_set_dir_addr_port(req, &my_dirport);
directory_request_set_directory_id_digest(req,
me->cache_info.identity_digest);
// ask via an anon circuit, connecting to our dirport.
directory_request_set_indirection(req, DIRIND_ANON_DIRPORT);
directory_request_set_resource(req, "authority.z");
directory_initiate_request(req);
directory_request_free(req);
}
}

View File

@ -947,6 +947,7 @@ authority_certs_fetch_resource_impl(const char *resource,
const dir_indirection_t indirection = get_via_tor ? DIRIND_ANONYMOUS
: DIRIND_ONEHOP;
directory_request_t *req = NULL;
/* If we've just downloaded a consensus from a bridge, re-use that
* bridge */
if (options->UseBridges && node && node->ri && !get_via_tor) {
@ -955,23 +956,26 @@ authority_certs_fetch_resource_impl(const char *resource,
/* we are willing to use a non-preferred address if we need to */
fascist_firewall_choose_address_node(node, FIREWALL_OR_CONNECTION, 0,
&or_ap);
directory_initiate_command(&or_ap.addr, or_ap.port,
NULL, 0, /*no dirport*/
dir_hint,
DIR_PURPOSE_FETCH_CERTIFICATE,
0,
indirection,
resource, NULL, 0, 0);
return;
req = directory_request_new(DIR_PURPOSE_FETCH_CERTIFICATE);
directory_request_set_or_addr_port(req, &or_ap);
if (dir_hint)
directory_request_set_directory_id_digest(req, dir_hint);
}
if (rs) {
/* If we've just downloaded a consensus from a directory, re-use that
* directory */
directory_initiate_command_routerstatus(rs,
DIR_PURPOSE_FETCH_CERTIFICATE,
0, indirection, resource, NULL,
0, 0, NULL);
req = directory_request_new(DIR_PURPOSE_FETCH_CERTIFICATE);
directory_request_set_routerstatus(req, rs);
}
if (req) {
/* Fill in the other request fields, and send the request. */
directory_request_set_indirection(req, indirection);
directory_request_set_resource(req, resource);
directory_initiate_request(req);
directory_request_free(req);
return;
}
@ -4932,10 +4936,11 @@ MOCK_IMPL(STATIC void, initiate_descriptor_downloads,
if (source) {
/* We know which authority or directory mirror we want. */
directory_initiate_command_routerstatus(source, purpose,
ROUTER_PURPOSE_GENERAL,
DIRIND_ONEHOP,
resource, NULL, 0, 0, NULL);
directory_request_t *req = directory_request_new(purpose);
directory_request_set_routerstatus(req, source);
directory_request_set_resource(req, resource);
directory_initiate_request(req);
directory_request_free(req);
} else {
directory_get_from_dirserver(purpose, ROUTER_PURPOSE_GENERAL, resource,
pds_flags, DL_WANT_ANY_DIRSERVER);