#ifndef TOR_RENDSERVICE_H
#define TOR_RENDSERVICE_H
#include "core/or/or.h"
#include "feature/hs/hs_service.h"
typedef struct rend_intro_cell_t rend_intro_cell_t;
struct config_line_t;
struct rend_intro_cell_t {
uint8_t type;
uint8_t pk[DIGEST_LEN];
uint8_t *ciphertext;
ssize_t ciphertext_len;
uint8_t *plaintext;
ssize_t plaintext_len;
uint8_t parsed;
uint8_t version;
union {
struct {
uint8_t rp[42];
} v0_v1;
struct {
extend_info_t *extend_info;
} v2;
struct {
uint8_t auth_type;
uint16_t auth_len;
uint8_t *auth_data;
extend_info_t *extend_info;
} v3;
} u;
uint8_t rc[REND_COOKIE_LEN];
uint8_t dh[DH1024_KEY_LEN];
};
#ifdef RENDSERVICE_PRIVATE
typedef struct rend_service_t {
char *directory;
int dir_group_readable;
smartlist_t *ports;
rend_auth_type_t auth_type;
smartlist_t *clients;
crypto_pk_t *private_key;
char service_id[REND_SERVICE_ID_LEN_BASE32+1];
char pk_digest[DIGEST_LEN];
smartlist_t *intro_nodes;
smartlist_t *expiring_nodes;
time_t intro_period_started;
int n_intro_circuits_launched;
unsigned int n_intro_points_wanted;
rend_service_descriptor_t *desc;
time_t desc_is_dirty;
time_t next_upload_time;
replaycache_t *accepted_intro_dh_parts;
int allow_unknown_ports;
int max_streams_per_circuit;
int max_streams_close_circuit;
} rend_service_t;
STATIC void rend_service_free_(rend_service_t *service);
#define rend_service_free(s) \
FREE_AND_NULL(rend_service_t, rend_service_free_, (s))
STATIC char *rend_service_sos_poison_path(const rend_service_t *service);
STATIC int rend_service_verify_single_onion_poison(
const rend_service_t *s,
const or_options_t *options);
STATIC int rend_service_poison_new_single_onion_dir(
const rend_service_t *s,
const or_options_t* options);
#ifdef TOR_UNIT_TESTS
STATIC void set_rend_service_list(smartlist_t *new_list);
STATIC void set_rend_rend_service_staging_list(smartlist_t *new_list);
STATIC void rend_service_prune_list_impl_(void);
#endif
#endif
int rend_num_services(void);
struct hs_opts_t;
int rend_config_service(const struct hs_opts_t *hs_opts,
const or_options_t *options,
hs_service_config_t *config);
void rend_service_prune_list(void);
void rend_service_free_staging_list(void);
int rend_service_load_all_keys(const smartlist_t *service_list);
int rend_service_key_on_disk(const char *directory_path);
void rend_services_add_filenames_to_lists(smartlist_t *open_lst,
smartlist_t *stat_lst);
void rend_consider_services_intro_points(time_t now);
void rend_consider_services_upload(time_t now);
void rend_hsdir_routers_changed(void);
void rend_consider_descriptor_republication(void);
void rend_service_intro_has_opened(origin_circuit_t *circuit);
int rend_service_intro_established(origin_circuit_t *circuit,
const uint8_t *request,
size_t request_len);
void rend_service_rendezvous_has_opened(origin_circuit_t *circuit);
int rend_service_receive_introduction(origin_circuit_t *circuit,
const uint8_t *request,
size_t request_len);
int rend_service_decrypt_intro(rend_intro_cell_t *request,
crypto_pk_t *key,
char **err_msg_out);
void rend_service_free_intro_(rend_intro_cell_t *request);
#define rend_service_free_intro(req) do { \
rend_service_free_intro_(req); \
(req) = NULL; \
} while (0)
rend_intro_cell_t * rend_service_begin_parse_intro(const uint8_t *request,
size_t request_len,
uint8_t type,
char **err_msg_out);
int rend_service_parse_intro_plaintext(rend_intro_cell_t *intro,
char **err_msg_out);
ssize_t rend_service_encode_establish_intro_cell(char *cell_body_out,
size_t cell_body_out_len,
crypto_pk_t *intro_key,
const char *rend_circ_nonce);
int rend_service_validate_intro_late(const rend_intro_cell_t *intro,
char **err_msg_out);
void rend_service_relaunch_rendezvous(origin_circuit_t *oldcirc);
int rend_service_set_connection_addr_port(edge_connection_t *conn,
origin_circuit_t *circ);
void rend_service_dump_stats(int severity);
void rend_service_free_all(void);
void rend_service_init(void);
rend_service_port_config_t *rend_service_parse_port_config(const char *string,
const char *sep,
char **err_msg_out);
void rend_service_port_config_free_(rend_service_port_config_t *p);
#define rend_service_port_config_free(p) \
FREE_AND_NULL(rend_service_port_config_t, rend_service_port_config_free_, \
(p))
void rend_authorized_client_free_(rend_authorized_client_t *client);
#define rend_authorized_client_free(client) \
FREE_AND_NULL(rend_authorized_client_t, rend_authorized_client_free_, \
(client))
hs_service_add_ephemeral_status_t rend_service_add_ephemeral(crypto_pk_t *pk,
smartlist_t *ports,
int max_streams_per_circuit,
int max_streams_close_circuit,
rend_auth_type_t auth_type,
smartlist_t *auth_clients,
char **service_id_out);
int rend_service_del_ephemeral(const char *service_id);
void directory_post_to_hs_dir(rend_service_descriptor_t *renddesc,
smartlist_t *descs, smartlist_t *hs_dirs,
const char *service_id, int seconds_valid);
void rend_service_desc_has_uploaded(const rend_data_t *rend_data);
int rend_service_allow_non_anonymous_connection(const or_options_t *options);
int rend_service_reveal_startup_time(const or_options_t *options);
int rend_service_non_anonymous_mode_enabled(const or_options_t *options);
#endif