#include "or.h"
#define REND_HID_SERV_DIR_REQUERY_PERIOD (15 * 60) |
The period for which a hidden service directory cannot be queried for the same descriptor ID again.
Referenced by directory_clean_last_hid_serv_requests(), and directory_get_from_hs_dir().
static void directory_clean_last_hid_serv_requests | ( | void | ) | [static] |
Clean the history of request times to hidden service directories, so that it does not contain requests older than REND_HID_SERV_DIR_REQUERY_PERIOD seconds any more.
References REND_HID_SERV_DIR_REQUERY_PERIOD, strmap_iter_done(), strmap_iter_get(), strmap_iter_init(), strmap_iter_next(), strmap_iter_next_rmv(), and tor_free.
Referenced by directory_get_from_hs_dir().
static int directory_get_from_hs_dir | ( | const char * | desc_id, | |
const rend_data_t * | rend_query | |||
) | [static] |
Determine the responsible hidden service directories for desc_id and fetch the descriptor belonging to that ID from one of them. Only send a request to hidden service directories that we did not try within the last REND_HID_SERV_DIR_REQUERY_PERIOD seconds; on success, return 1, in the case that no hidden service directory is left to ask for the descriptor, return 0, and in case of a failure -1. query is only passed for pretty log statements.
References rend_data_t::auth_type, base32_encode(), base64_encode(), rend_data_t::descriptor_cookie, DIGEST_LEN, DIR_PURPOSE_FETCH_RENDDESC_V2, directory_clean_last_hid_serv_requests(), directory_initiate_command_routerstatus_rend(), escaped_safe_str_client(), hid_serv_get_responsible_directories(), LD_BUG, LD_REND, lookup_last_hid_serv_request(), rend_data_t::onion_address, REND_DESC_COOKIE_LEN, REND_DESC_COOKIE_LEN_BASE64, REND_DESC_ID_V2_LEN_BASE32, REND_HID_SERV_DIR_REQUERY_PERIOD, router_get_by_digest(), ROUTER_PURPOSE_GENERAL, smartlist_choose(), smartlist_create(), smartlist_free(), and tor_assert.
Referenced by rend_client_refetch_v2_renddesc().
static time_t lookup_last_hid_serv_request | ( | routerstatus_t * | hs_dir, | |
const char * | desc_id_base32, | |||
time_t | now, | |||
int | set | |||
) | [static] |
Look up the last request time to hidden service directory hs_dir for descriptor ID desc_id_base32. If set is non-zero, assign the current time now and return that. Otherwise, return the most recent request time, or 0 if no such request has been sent before.
References base32_encode(), DIGEST_LEN, routerstatus_t::identity_digest, REND_DESC_ID_V2_LEN_BASE32, strmap_get_lc(), strmap_set(), tor_free, and tor_snprintf().
Referenced by directory_get_from_hs_dir().
void rend_client_desc_trynow | ( | const char * | query | ) |
Find all the apconns in state AP_CONN_STATE_RENDDESC_WAIT that are waiting on query. If there's a working cache entry here with at least one intro point, move them to the next state.
References edge_connection_t::_base, AP_CONN_STATE_CIRCUIT_WAIT, AP_CONN_STATE_RENDDESC_WAIT, assert_connection_ok(), CONN_TYPE_AP, connection_ap_handshake_attach_circuit(), END_STREAM_REASON_CANT_ATTACH, get_connection_array(), rend_service_descriptor_t::intro_nodes, LD_REND, connection_t::marked_for_close, rend_data_t::onion_address, rend_cache_entry_t::parsed, rend_cache_lookup_entry(), rend_cmp_service_ids(), edge_connection_t::rend_data, safe_str_client(), connection_t::state, connection_t::timestamp_created, connection_t::timestamp_lastread, connection_t::timestamp_lastwritten, TO_CONN, and TO_EDGE_CONN().
Referenced by connection_dir_client_reached_eof(), and rend_client_refetch_v2_renddesc().
extend_info_t* rend_client_get_random_intro | ( | const rend_data_t * | rend_query | ) |
Return a newly allocated extend_info_t* for a randomly chosen introduction point for the named hidden service. Return NULL if all introduction points have been tried and failed.
References crypto_rand_int(), rend_intro_point_t::extend_info, extend_info_dup(), extend_info_free(), extend_info_from_router(), rend_service_descriptor_t::intro_nodes, LD_REND, extend_info_t::nickname, rend_data_t::onion_address, extend_info_t::onion_key, rend_cache_entry_t::parsed, rend_cache_lookup_entry(), rend_intro_point_free(), router_get_by_nickname(), safe_str_client(), and smartlist_del().
Referenced by circuit_get_open_circ_or_launch(), and rend_client_introduction_acked().
void rend_client_introcirc_has_opened | ( | origin_circuit_t * | circ | ) |
Called when we've established a circuit to an introduction point: send the introduction request.
References origin_circuit_t::_base, CIRCUIT_PURPOSE_C_INTRODUCING, connection_ap_attach_pending(), origin_circuit_t::cpath, LD_REND, circuit_t::purpose, and tor_assert.
Referenced by circuit_has_opened().
int rend_client_introduction_acked | ( | origin_circuit_t * | circ, | |
const char * | request, | |||
size_t | request_len | |||
) |
Called when get an ACK or a NAK for a REND_INTRODUCE1 cell.
References origin_circuit_t::_base, origin_circuit_t::build_state, cpath_build_state_t::chosen_exit, CIRCLAUNCH_IS_INTERNAL, circuit_extend_to_new_exit(), circuit_get_by_rend_query_and_purpose(), circuit_launch_by_extend_info(), CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT, CIRCUIT_PURPOSE_C_INTRODUCE_ACKED, CIRCUIT_PURPOSE_C_INTRODUCING, CIRCUIT_PURPOSE_C_REND_READY, CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED, escaped_safe_str_client(), extend_info_free(), LD_PROTOCOL, LD_REND, circuit_t::n_circ_id, extend_info_t::nickname, rend_data_t::onion_address, circuit_t::purpose, origin_circuit_t::remaining_relay_early_cells, rend_client_get_random_intro(), rend_client_remove_intro_point(), origin_circuit_t::rend_data, TO_CIRCUIT, and tor_assert.
Referenced by rend_process_relay_cell().
rend_service_authorization_t* rend_client_lookup_service_authorization | ( | const char * | onion_address | ) |
Look up the client-side authorization for the hidden service with onion_address. Return NULL if no authorization is available for that address.
References strmap_get(), and tor_assert.
int rend_client_receive_rendezvous | ( | origin_circuit_t * | circ, | |
const char * | request, | |||
size_t | request_len | |||
) |
Bob sent us a rendezvous cell; join the circuits.
References origin_circuit_t::_base, origin_circuit_t::build_state, circuit_init_cpath_crypto(), circuit_initial_package_window(), CIRCUIT_PURPOSE_C_REND_JOINED, CIRCUIT_PURPOSE_C_REND_READY, CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED, CIRCWINDOW_START, connection_ap_attach_pending(), origin_circuit_t::cpath, crypto_dh_compute_secret(), crypto_dh_free(), crypt_path_t::deliver_window, crypt_path_t::dh_handshake_state, DIGEST_LEN, LD_GENERAL, LD_PROTOCOL, LD_REND, onion_append_to_cpath(), crypt_path_t::package_window, cpath_build_state_t::pending_final_cpath, circuit_t::purpose, crypt_path_t::state, TO_CIRCUIT, and tor_assert.
Referenced by rend_process_relay_cell().
void rend_client_refetch_v2_renddesc | ( | const rend_data_t * | rend_query | ) |
Unless we already have a descriptor for rend_query with at least one (possibly) working introduction point in it, start a connection to a hidden service directory to fetch a v2 rendezvous service descriptor.
References rend_data_t::auth_type, crypto_rand_int(), rend_data_t::descriptor_cookie, DIGEST_LEN, directory_get_from_hs_dir(), get_options(), LD_REND, rend_data_t::onion_address, rend_cache_lookup_entry(), rend_client_desc_trynow(), rend_compute_v2_desc_id(), REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS, safe_str_client(), and tor_assert.
Referenced by circuit_get_open_circ_or_launch(), connection_about_to_close_connection(), and rend_client_remove_intro_point().
int rend_client_remove_intro_point | ( | extend_info_t * | failed_intro, | |
const rend_data_t * | rend_query | |||
) |
Remove failed_intro from ent. If ent now has no intro points, or service is unrecognized, then launch a new renddesc fetch.
Return -1 if error, 0 if no intro points remain or service unrecognized, 1 if recognized and some intro points remain.
References AP_CONN_STATE_CIRCUIT_WAIT, AP_CONN_STATE_RENDDESC_WAIT, CONN_TYPE_AP, connection_get_by_type_state_rendquery(), DIGEST_LEN, escaped_safe_str_client(), rend_intro_point_t::extend_info, extend_info_t::identity_digest, rend_service_descriptor_t::intro_nodes, LD_BUG, LD_REND, rend_data_t::onion_address, rend_cache_entry_t::parsed, rend_cache_lookup_entry(), rend_client_refetch_v2_renddesc(), rend_intro_point_free(), smartlist_del(), and connection_t::state.
Referenced by _circuit_mark_for_close(), and rend_client_introduction_acked().
void rend_client_rendcirc_has_opened | ( | origin_circuit_t * | circ | ) |
Called when a rendezvous circuit is open; sends a establish rendezvous circuit as appropriate.
References origin_circuit_t::_base, CIRCUIT_PURPOSE_C_ESTABLISH_REND, LD_REND, circuit_t::purpose, rend_client_send_establish_rendezvous(), and tor_assert.
Referenced by circuit_get_open_circ_or_launch(), and circuit_has_opened().
int rend_client_rendezvous_acked | ( | origin_circuit_t * | circ, | |
const char * | request, | |||
size_t | request_len | |||
) |
Called when we receive a RENDEZVOUS_ESTABLISHED cell; changes the state of the circuit to C_REND_READY.
References origin_circuit_t::_base, CIRCUIT_PURPOSE_C_ESTABLISH_REND, CIRCUIT_PURPOSE_C_REND_READY, connection_ap_attach_pending(), LD_PROTOCOL, LD_REND, circuit_t::purpose, and TO_CIRCUIT.
Referenced by rend_process_relay_cell().
static int rend_client_send_establish_rendezvous | ( | origin_circuit_t * | circ | ) | [static] |
Send the establish-rendezvous cell along a rendezvous circuit. if it fails, mark the circ for close and return -1. else return 0.
References origin_circuit_t::_base, CIRCUIT_PURPOSE_C_ESTABLISH_REND, origin_circuit_t::cpath, crypto_rand(), LD_BUG, LD_GENERAL, LD_REND, crypt_path_t::prev, circuit_t::purpose, relay_send_command_from_edge(), rend_data_t::rend_cookie, REND_COOKIE_LEN, origin_circuit_t::rend_data, TO_CIRCUIT, and tor_assert.
Referenced by rend_client_rendcirc_has_opened().
int rend_client_send_introduction | ( | origin_circuit_t * | introcirc, | |
origin_circuit_t * | rendcirc | |||
) |
Called when we're trying to connect an ap conn; sends an INTRODUCE1 cell down introcirc if possible.
References origin_circuit_t::_base, origin_circuit_t::build_state, cpath_build_state_t::chosen_exit, CIRCUIT_PURPOSE_C_INTRODUCING, CIRCUIT_PURPOSE_C_REND_READY, DIGEST_LEN, escaped_safe_str_client(), extend_info_t::identity_digest, rend_service_descriptor_t::intro_nodes, LD_REND, rend_data_t::onion_address, rend_cache_entry_t::parsed, circuit_t::purpose, RELAY_PAYLOAD_SIZE, rend_cache_lookup_entry(), rend_cmp_service_ids(), origin_circuit_t::rend_data, and tor_assert.
Referenced by connection_ap_handshake_attach_circuit().
int rend_parse_service_authorization | ( | or_options_t * | options, | |
int | validate_only | |||
) |
Parse config_line as a client-side authorization for a hidden service and add it to the local map of hidden service authorizations. Return 0 for success and -1 for failure.
References rend_service_authorization_t::auth_type, base64_decode(), rend_service_authorization_t::descriptor_cookie, or_options_t::HidServAuth, LD_CONFIG, config_line_t::next, rend_service_authorization_t::onion_address, REND_DESC_COOKIE_LEN, REND_DESC_COOKIE_LEN_BASE64, REND_SERVICE_ADDRESS_LEN, rend_service_authorization_free(), rend_service_authorization_free_all(), rend_service_authorization_strmap_item_free(), REND_SERVICE_ID_LEN_BASE32, rend_valid_service_id(), smartlist_clear(), smartlist_create(), smartlist_free(), smartlist_split_string(), strcmpend(), strmap_free(), strmap_get(), strmap_set(), tor_free, tor_snprintf(), and config_line_t::value.
Referenced by options_act().
static void rend_service_authorization_free | ( | rend_service_authorization_t * | auth | ) | [static] |
Helper: Free storage held by rend_service_authorization_t.
References tor_free.
Referenced by rend_parse_service_authorization(), and rend_service_authorization_strmap_item_free().
void rend_service_authorization_free_all | ( | void | ) |
Release all the storage held in auth_hid_servs.
References rend_service_authorization_strmap_item_free(), and strmap_free().
Referenced by rend_parse_service_authorization(), and tor_free_all().
static void rend_service_authorization_strmap_item_free | ( | void * | service_auth | ) | [static] |
Helper for strmap_free.
References rend_service_authorization_free().
Referenced by rend_parse_service_authorization(), and rend_service_authorization_free_all().
strmap_t* auth_hid_servs = NULL [static] |
Client-side authorizations for hidden services; map of onion address to rend_service_authorization_t*.
strmap_t* last_hid_serv_requests = NULL [static] |
Contains the last request times to hidden service directories for certain queries; keys are strings consisting of base32-encoded hidden service directory identities and base32-encoded descriptor IDs; values are pointers to timestamps of the last requests.