tor  master
Macros | Functions
hs_service.c File Reference

Implement next generation hidden service functionality. More...

#include "or.h"
#include "circpathbias.h"
#include "circuitbuild.h"
#include "circuitlist.h"
#include "circuituse.h"
#include "config.h"
#include "connection.h"
#include "crypto_rand.h"
#include "crypto_util.h"
#include "directory.h"
#include "main.h"
#include "networkstatus.h"
#include "nodelist.h"
#include "relay.h"
#include "rendservice.h"
#include "router.h"
#include "routerkeys.h"
#include "routerlist.h"
#include "shared_random_client.h"
#include "statefile.h"
#include "hs_circuit.h"
#include "hs_common.h"
#include "hs_config.h"
#include "hs_control.h"
#include "hs_descriptor.h"
#include "hs_ident.h"
#include "hs_intropoint.h"
#include "hs_service.h"
#include "hs_stats.h"
#include "ed25519_cert.h"
#include "hs/cell_common.h"
#include "hs/cell_establish_intro.h"
Include dependency graph for hs_service.c:

Macros

#define HS_SERVICE_PRIVATE
 
#define FOR_EACH_SERVICE_BEGIN(var)
 
#define FOR_EACH_SERVICE_END   } STMT_END ;
 
#define FOR_EACH_DESCRIPTOR_BEGIN(service, var)
 
#define FOR_EACH_DESCRIPTOR_END   } STMT_END ;
 
#define MIN_INTRO_POINT_LIFETIME_TESTING   10
 
#define MAX_INTRO_POINT_LIFETIME_TESTING   30
 
#define MAX_INTRO_POINT_CIRCUIT_RETRIES_TESTING   -1
 
#define MAX_STREAM_WARN_INTERVAL   600
 

Functions

 HT_PROTOTYPE (HT_GENERATE2(hs_service_ht, HT_GENERATE2(hs_service_t, HT_GENERATE2(hs_service_node, HT_GENERATE2(hs_service_ht_hash, HT_GENERATE2(hs_service_ht_eq)
 
STATIC int register_service (hs_service_ht *map, hs_service_t *service)
 
STATIC void remove_service (hs_service_ht *map, hs_service_t *service)
 
STATIC void service_intro_point_free_ (hs_service_intro_point_t *ip)
 
STATIC hs_service_intro_point_tservice_intro_point_new (const extend_info_t *ei, unsigned int is_legacy)
 
STATIC void service_intro_point_add (digest256map_t *map, hs_service_intro_point_t *ip)
 
STATIC void service_intro_point_remove (const hs_service_t *service, const hs_service_intro_point_t *ip)
 
STATIC hs_service_intro_point_tservice_intro_point_find (const hs_service_t *service, const ed25519_public_key_t *auth_key)
 
STATIC hs_service_descriptor_tservice_desc_find_by_intro (const hs_service_t *service, const hs_service_intro_point_t *ip)
 
STATIC void get_objects_from_ident (const hs_ident_circuit_t *ident, hs_service_t **service, hs_service_intro_point_t **ip, hs_service_descriptor_t **desc)
 
STATIC const node_tget_node_from_intro_point (const hs_service_intro_point_t *ip)
 
STATIC int write_address_to_file (const hs_service_t *service, const char *fname_)
 
STATIC void service_descriptor_free_ (hs_service_descriptor_t *desc)
 
STATIC hs_service_descriptor_tservice_descriptor_new (void)
 
STATIC void build_all_descriptors (time_t now)
 
STATIC void service_desc_schedule_upload (hs_service_descriptor_t *desc, time_t now, int descriptor_changed)
 
STATIC void update_all_descriptors (time_t now)
 
STATIC int intro_point_should_expire (const hs_service_intro_point_t *ip, time_t now)
 
STATIC void rotate_all_descriptors (time_t now)
 
STATIC void run_housekeeping_event (time_t now)
 
STATIC int can_service_launch_intro_circuit (hs_service_t *service, time_t now)
 
STATIC char * encode_desc_rev_counter_for_state (const hs_service_descriptor_t *desc)
 
STATIC uint64_t check_state_line_for_service_rev_counter (const char *state_line, const ed25519_public_key_t *blinded_pubkey, int *service_found_out)
 
STATIC void upload_descriptor_to_all (const hs_service_t *service, hs_service_descriptor_t *desc)
 
STATIC int service_desc_hsdirs_changed (const hs_service_t *service, const hs_service_descriptor_t *desc)
 
STATIC void run_upload_descriptor_event (time_t now)
 
void hs_service_map_has_changed (void)
 
void hs_service_upload_desc_to_dir (const char *encoded_desc, const uint8_t version, const ed25519_public_key_t *identity_pk, const ed25519_public_key_t *blinded_pk, const routerstatus_t *hsdir_rs)
 
hs_service_add_ephemeral_status_t hs_service_add_ephemeral (ed25519_secret_key_t *sk, smartlist_t *ports, int max_streams_per_rdv_circuit, int max_streams_close_circuit, char **address_out)
 
int hs_service_del_ephemeral (const char *address)
 
char * hs_service_lookup_current_desc (const ed25519_public_key_t *pk)
 
unsigned int hs_service_get_num_services (void)
 
void hs_service_intro_circ_has_closed (origin_circuit_t *circ)
 
int hs_service_set_conn_addr_port (const origin_circuit_t *circ, edge_connection_t *conn)
 
void hs_service_lists_fnames_for_sandbox (smartlist_t *file_list, smartlist_t *dir_list)
 
void hs_service_dir_info_changed (void)
 
int hs_service_receive_introduce2 (origin_circuit_t *circ, const uint8_t *payload, size_t payload_len)
 
int hs_service_receive_intro_established (origin_circuit_t *circ, const uint8_t *payload, size_t payload_len)
 
void hs_service_circuit_has_opened (origin_circuit_t *circ)
 
int hs_service_load_all_keys (void)
 
void hs_service_stage_services (const smartlist_t *service_list)
 
hs_service_ths_service_new (const or_options_t *options)
 
void hs_service_free_ (hs_service_t *service)
 
void hs_service_run_scheduled_events (time_t now)
 
void hs_service_init (void)
 
void hs_service_free_all (void)
 

Detailed Description

Implement next generation hidden service functionality.

Macro Definition Documentation

◆ FOR_EACH_DESCRIPTOR_BEGIN

#define FOR_EACH_DESCRIPTOR_BEGIN (   service,
  var 
)
Value:
STMT_BEGIN \
hs_service_descriptor_t *var; \
for (int var ## _loop_idx = 0; var ## _loop_idx < 2; \
++var ## _loop_idx) { \
(var ## _loop_idx == 0) ? (var = service->desc_current) : \
(var = service->desc_next); \
if (var == NULL) continue;

◆ FOR_EACH_SERVICE_BEGIN

#define FOR_EACH_SERVICE_BEGIN (   var)
Value:
STMT_BEGIN \
hs_service_t **var##_iter, *var; \
HT_FOREACH(var##_iter, hs_service_ht, hs_service_map) { \
var = *var##_iter;

Function Documentation

◆ check_state_line_for_service_rev_counter()

STATIC uint64_t check_state_line_for_service_rev_counter ( const char *  state_line,
const ed25519_public_key_t blinded_pubkey,
int *  service_found_out 
)

Scan the string state_line for the revision counter of the service with blinded_pubkey. Set service_found_out to True if the line is relevant to this service, and return the cached revision counter. Else set service_found_out to False.

Here is the call graph for this function:

◆ encode_desc_rev_counter_for_state()

STATIC char* encode_desc_rev_counter_for_state ( const hs_service_descriptor_t desc)

Return a newly-allocated string for our state file which contains revision counter information for desc. The format is:

HidServRevCounter <blinded_pubkey> <rev_counter>

Here is the call graph for this function:

◆ service_desc_hsdirs_changed()

STATIC int service_desc_hsdirs_changed ( const hs_service_t service,
const hs_service_descriptor_t desc 
)

The set of HSDirs have changed: check if the change affects our descriptor HSDir placement, and if it does, reupload the desc.

◆ service_desc_schedule_upload()

STATIC void service_desc_schedule_upload ( hs_service_descriptor_t desc,
time_t  now,
int  descriptor_changed 
)

Schedule an upload of desc. If descriptor_changed is set, it means that this descriptor is dirty.

◆ upload_descriptor_to_all()

STATIC void upload_descriptor_to_all ( const hs_service_t service,
hs_service_descriptor_t desc 
)

Clear list of previous hsdirs since we are about to upload to a new list. Let's keep it up to date.