rendservice.c File Reference

The hidden-service side of rendezvous functionality. More...

#include "or.h"

Data Structures

struct  rend_service_port_config_t
struct  rend_service_t

Defines

#define NUM_INTRO_POINTS   3
#define INTRO_CIRC_RETRY_PERIOD   (60*5)
#define MAX_INTRO_CIRCS_PER_PERIOD   10
#define MAX_REND_FAILURES   30
#define MAX_REND_TIMEOUT   30
#define NUM_INTRO_POINTS_INIT   (NUM_INTRO_POINTS + 2)

Functions

static origin_circuit_tfind_intro_circuit (rend_intro_point_t *intro, const char *pk_digest)
int num_rend_services (void)
static void rend_authorized_client_free (rend_authorized_client_t *client)
static void rend_authorized_client_strmap_item_free (void *authorized_client)
static void rend_service_free (rend_service_t *service)
void rend_service_free_all (void)
static void rend_add_service (rend_service_t *service)
static rend_service_port_config_tparse_port_config (const char *string)
int rend_config_services (or_options_t *options, int validate_only)
static void rend_service_update_descriptor (rend_service_t *service)
int rend_service_load_keys (void)
static rend_service_trend_service_get_by_pk_digest (const char *digest)
static int rend_service_requires_uptime (rend_service_t *service)
static int rend_check_authorization (rend_service_t *service, const char *descriptor_cookie)
static void clean_accepted_intros (rend_service_t *service, time_t now)
int rend_service_introduce (origin_circuit_t *circuit, const char *request, size_t request_len)
void rend_service_relaunch_rendezvous (origin_circuit_t *oldcirc)
static int rend_service_launch_establish_intro (rend_service_t *service, rend_intro_point_t *intro)
static int count_established_intro_points (const char *query)
void rend_service_intro_has_opened (origin_circuit_t *circuit)
int rend_service_intro_established (origin_circuit_t *circuit, const char *request, size_t request_len)
void rend_service_rendezvous_has_opened (origin_circuit_t *circuit)
static void directory_post_to_hs_dir (rend_service_descriptor_t *renddesc, smartlist_t *descs, const char *service_id, int seconds_valid)
static void upload_service_descriptor (rend_service_t *service)
void rend_services_introduce (void)
void rend_consider_services_upload (time_t now)
void rend_hsdir_routers_changed (void)
void rend_consider_descriptor_republication (void)
void rend_service_dump_stats (int severity)
int rend_service_set_connection_addr_port (edge_connection_t *conn, origin_circuit_t *circ)

Variables

static smartlist_trend_service_list = NULL
static int consider_republishing_rend_descriptors = 1


Detailed Description

The hidden-service side of rendezvous functionality.


Define Documentation

#define INTRO_CIRC_RETRY_PERIOD   (60*5)

If we can't build our intro circuits, don't retry for this long.

Referenced by rend_services_introduce().

#define MAX_INTRO_CIRCS_PER_PERIOD   10

Don't try to build more than this many circuits before giving up for a while.

Referenced by rend_services_introduce().

#define MAX_REND_FAILURES   30

How many times will a hidden service operator attempt to connect to a requested rendezvous point before giving up?

Referenced by rend_service_introduce(), and rend_service_relaunch_rendezvous().

#define MAX_REND_TIMEOUT   30

How many seconds should we spend trying to connect to a requested rendezvous point before giving up?

Referenced by rend_service_introduce().

#define NUM_INTRO_POINTS   3

Try to maintain this many intro points per service if possible.

Referenced by rend_service_intro_has_opened().


Function Documentation

static void clean_accepted_intros ( rend_service_t service,
time_t  now 
) [static]

Remove elements from service's replay cache that are old enough to be noticed by timestamp checking.

References rend_service_t::accepted_intros, rend_service_t::last_cleaned_accepted_intros, REND_REPLAY_TIME_INTERVAL, and tor_free.

Referenced by rend_service_introduce().

static int count_established_intro_points ( const char *  query  )  [static]

static void directory_post_to_hs_dir ( rend_service_descriptor_t renddesc,
smartlist_t descs,
const char *  service_id,
int  seconds_valid 
) [static]

static origin_circuit_t * find_intro_circuit ( rend_intro_point_t intro,
const char *  pk_digest 
) [static]

Return the (possibly non-open) introduction circuit ending at intro for the service whose public key is pk_digest. (desc_version is ignored). Return NULL if no such service is found.

References origin_circuit_t::build_state, cpath_build_state_t::chosen_exit, circuit_get_next_by_pk_and_purpose(), CIRCUIT_PURPOSE_S_ESTABLISH_INTRO, CIRCUIT_PURPOSE_S_INTRO, DIGEST_LEN, rend_intro_point_t::extend_info, extend_info_t::identity_digest, origin_circuit_t::rend_data, and tor_assert.

Referenced by rend_service_dump_stats(), rend_service_update_descriptor(), and rend_services_introduce().

int num_rend_services ( void   ) 

Return the number of rendezvous services we have configured.

Referenced by circuit_predict_and_launch_new().

static rend_service_port_config_t* parse_port_config ( const char *  string  )  [static]

Parses a real-port to virtual-port mapping and returns a new rend_service_port_config_t.

The format is: VirtualPort (IP|RealPort|IP:RealPort)?

IP defaults to 127.0.0.1; RealPort defaults to VirtualPort.

References escaped(), LD_CONFIG, rend_service_port_config_t::real_addr, rend_service_port_config_t::real_port, smartlist_create(), smartlist_free(), smartlist_split_string(), tor_addr_copy(), tor_addr_from_ipv4h, tor_addr_port_parse(), tor_free, tor_parse_long(), and rend_service_port_config_t::virtual_port.

Referenced by rend_config_services().

static void rend_add_service ( rend_service_t service  )  [static]

static void rend_authorized_client_free ( rend_authorized_client_t client  )  [static]

Helper: free storage held by a single service authorized client entry.

References rend_authorized_client_t::client_key, rend_authorized_client_t::client_name, crypto_free_pk_env(), and tor_free.

Referenced by rend_authorized_client_strmap_item_free(), and rend_service_free().

static void rend_authorized_client_strmap_item_free ( void *  authorized_client  )  [static]

Helper for strmap_free.

References rend_authorized_client_free().

Referenced by rend_service_load_keys().

static int rend_check_authorization ( rend_service_t service,
const char *  descriptor_cookie 
) [static]

Check client authorization of a given descriptor_cookie for service. Return 1 for success and 0 for failure.

References rend_service_t::clients, LD_BUG, REND_DESC_COOKIE_LEN, and tor_assert.

Referenced by rend_service_introduce().

int rend_config_services ( or_options_t options,
int  validate_only 
)

void rend_consider_descriptor_republication ( void   ) 

Consider republication of v2 rendezvous service descriptors that failed previously, but without regenerating descriptor contents.

References rend_service_descriptor_t::all_uploads_performed, rend_service_t::desc, get_options(), and upload_service_descriptor().

Referenced by run_scheduled_events().

void rend_consider_services_upload ( time_t  now  ) 

Regenerate and upload rendezvous service descriptors for all services, if necessary. If the descriptor has been dirty enough for long enough, definitely upload; else only upload when the periodic timeout has expired.

For the first upload, pick a random time between now and two periods from now, and pick it independently for each service.

References crypto_rand_int(), rend_service_t::desc_is_dirty, get_options(), rend_service_t::next_upload_time, rend_service_update_descriptor(), or_options_t::RendPostPeriod, and upload_service_descriptor().

Referenced by run_scheduled_events().

void rend_hsdir_routers_changed ( void   ) 

Called when our internal view of the directory has changed, so that we might have router descriptors of hidden service directories available that we did not have before.

Referenced by router_dir_info_changed().

void rend_service_dump_stats ( int  severity  ) 

static void rend_service_free ( rend_service_t service  )  [static]

void rend_service_free_all ( void   ) 

Release all the storage held in rend_service_list.

References rend_service_free(), and smartlist_free().

Referenced by tor_free_all().

static rend_service_t* rend_service_get_by_pk_digest ( const char *  digest  )  [static]

Return the service whose public key has a digest of digest, or NULL if no such service exists.

References DIGEST_LEN.

Referenced by rend_service_intro_established(), rend_service_intro_has_opened(), rend_service_introduce(), rend_service_rendezvous_has_opened(), and rend_service_set_connection_addr_port().

int rend_service_intro_established ( origin_circuit_t circuit,
const char *  request,
size_t  request_len 
)

void rend_service_intro_has_opened ( origin_circuit_t circuit  ) 

int rend_service_introduce ( origin_circuit_t circuit,
const char *  request,
size_t  request_len 
)

Respond to an INTRODUCE2 cell by launching a circuit to the chosen rendezvous point.

References origin_circuit_t::_base, rend_service_t::accepted_intros, extend_info_t::addr, base16_encode(), base32_encode(), origin_circuit_t::build_state, CIRCLAUNCH_IS_INTERNAL, CIRCLAUNCH_NEED_CAPACITY, CIRCLAUNCH_NEED_UPTIME, circuit_init_cpath_crypto(), circuit_launch_by_extend_info(), CIRCUIT_PURPOSE_S_CONNECT_REND, CIRCUIT_PURPOSE_S_INTRO, clean_accepted_intros(), rend_service_t::clients, crypto_dh_compute_secret(), crypto_dh_free(), crypto_dh_generate_public(), crypto_dh_new(), crypto_digest_add_bytes(), crypto_digest_get_digest(), crypto_free_digest_env(), crypto_new_digest_env(), crypto_pk_asn1_decode(), crypto_pk_get_digest(), crypto_pk_keysize(), crypto_pk_private_hybrid_decrypt(), crypt_path_t::dh_handshake_state, DIGEST_LEN, digestmap_get(), digestmap_new(), digestmap_set(), escaped(), escaped_safe_str_client(), cpath_build_state_t::expiry_time, extend_info_free(), extend_info_from_router(), get_uint16(), get_uint32(), crypt_path_t::handshake_digest, extend_info_t::identity_digest, origin_circuit_t::intro_key, is_legal_nickname(), is_legal_nickname_or_hexdigest(), rend_service_t::last_cleaned_accepted_intros, LD_BUG, LD_PROTOCOL, LD_REND, crypt_path_t::magic, MAX_HEX_NICKNAME_LEN, MAX_NICKNAME_LEN, MAX_REND_FAILURES, MAX_REND_TIMEOUT, circuit_t::n_circ_id, extend_info_t::nickname, note_crypto_pk_op(), rend_data_t::onion_address, extend_info_t::onion_key, cpath_build_state_t::pending_final_cpath, PK_PKCS1_OAEP_PADDING, extend_info_t::port, circuit_t::purpose, RELAY_PAYLOAD_SIZE, rend_check_authorization(), rend_data_t::rend_cookie, REND_COOKIE_LEN, origin_circuit_t::rend_data, REND_DESC_COOKIE_LEN, rend_data_t::rend_pk_digest, REND_REPLAY_TIME_INTERVAL, rend_service_get_by_pk_digest(), REND_SERVICE_ID_LEN, REND_SERVICE_ID_LEN_BASE32, rend_service_requires_uptime(), rep_hist_note_used_internal(), router_get_by_nickname(), rend_service_t::service_id, TO_CIRCUIT, tor_addr_from_ipv4n(), and tor_assert.

Referenced by rend_process_relay_cell().

static int rend_service_launch_establish_intro ( rend_service_t service,
rend_intro_point_t intro 
) [static]

int rend_service_load_keys ( void   ) 

void rend_service_relaunch_rendezvous ( origin_circuit_t oldcirc  ) 

void rend_service_rendezvous_has_opened ( origin_circuit_t circuit  ) 

static int rend_service_requires_uptime ( rend_service_t service  )  [static]

Return 1 if any virtual port in service wants a circuit to have good uptime. Else return 0.

References get_options(), rend_service_t::ports, smartlist_string_num_isin(), and rend_service_port_config_t::virtual_port.

Referenced by rend_service_introduce().

int rend_service_set_connection_addr_port ( edge_connection_t conn,
origin_circuit_t circ 
)

Given conn, a rendezvous exit stream, look up the hidden service for 'circ', and look up the port and address based on conn->port. Assign the actual conn->addr and conn->port. Return -1 if failure, or 0 for success.

References edge_connection_t::_base, origin_circuit_t::_base, base32_encode(), CIRCUIT_PURPOSE_S_REND_JOINED, LD_REND, circuit_t::n_circ_id, connection_t::port, rend_service_t::ports, circuit_t::purpose, origin_circuit_t::rend_data, rend_data_t::rend_pk_digest, rend_service_get_by_pk_digest(), REND_SERVICE_ID_LEN, REND_SERVICE_ID_LEN_BASE32, smartlist_add(), smartlist_create(), and tor_assert.

Referenced by connection_exit_begin_conn().

static void rend_service_update_descriptor ( rend_service_t service  )  [static]

void rend_services_introduce ( void   ) 

static void upload_service_descriptor ( rend_service_t service  )  [static]


Variable Documentation

True if the list of available router descriptors might have changed so that we should have a look whether we can republish previously failed rendezvous service descriptors.

smartlist_t* rend_service_list = NULL [static]

A list of rend_service_t's for services run on this OP.


Generated on Tue May 25 00:30:49 2010 for tor by  doxygen 1.5.6