15 #include "testsupport.h" 17 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(DARWIN) 18 #define KERNEL_MAY_SUPPORT_IPFW 23 #define MIN_HEARTBEAT_PERIOD (30*60) 26 #if SIZEOF_VOID_P >= 8 27 #define MAX_DEFAULT_MEMORY_QUEUE_SIZE (U64_LITERAL(8) << 30) 29 #define MAX_DEFAULT_MEMORY_QUEUE_SIZE (U64_LITERAL(2) << 30) 32 MOCK_DECL(
const char*, get_dirportfrontpage, (
void));
38 const char *
safe_str(
const char *address);
52 const char **method_out,
char **hostname_out);
56 #define OPTIONS_DUMP_MINIMAL 1 57 #define OPTIONS_DUMP_DEFAULTS 2 58 #define OPTIONS_DUMP_ALL 3 62 int command,
const char *command_arg,
char **msg);
76 options_get_dir_fname2_suffix,
78 directory_root_t roottype,
79 const char *sub1,
const char *sub2,
99 #define options_get_datadir_fname2_suffix(options, sub1, sub2, suffix) \ 100 options_get_dir_fname2_suffix((options), DIRROOT_DATADIR, \ 101 (sub1), (sub2), (suffix)) 102 #define options_get_cachedir_fname2_suffix(options, sub1, sub2, suffix) \ 103 options_get_dir_fname2_suffix((options), DIRROOT_CACHEDIR, \ 104 (sub1), (sub2), (suffix)) 105 #define options_get_keydir_fname2_suffix(options, sub1, sub2, suffix) \ 106 options_get_dir_fname2_suffix((options), DIRROOT_KEYDIR, \ 107 (sub1), (sub2), (suffix)) 109 #define options_get_datadir_fname(opts,sub1) \ 110 options_get_datadir_fname2_suffix((opts),(sub1), NULL, NULL) 111 #define options_get_datadir_fname2(opts,sub1,sub2) \ 112 options_get_datadir_fname2_suffix((opts),(sub1), (sub2), NULL) 114 #define get_datadir_fname2_suffix(sub1, sub2, suffix) \ 115 options_get_datadir_fname2_suffix(get_options(), (sub1), (sub2), (suffix)) 116 #define get_datadir_fname(sub1) \ 117 get_datadir_fname2_suffix((sub1), NULL, NULL) 118 #define get_datadir_fname2(sub1,sub2) \ 119 get_datadir_fname2_suffix((sub1), (sub2), NULL) 120 #define get_datadir_fname_suffix(sub1, suffix) \ 121 get_datadir_fname2_suffix((sub1), NULL, (suffix)) 124 #define options_get_keydir_fname(options, sub1) \ 125 options_get_keydir_fname2_suffix((options), (sub1), NULL, NULL) 126 #define get_keydir_fname_suffix(sub1, suffix) \ 127 options_get_keydir_fname2_suffix(get_options(), (sub1), NULL, suffix) 128 #define get_keydir_fname(sub1) \ 129 options_get_keydir_fname2_suffix(get_options(), (sub1), NULL, NULL) 131 #define get_cachedir_fname(sub1) \ 132 options_get_cachedir_fname2_suffix(get_options(), (sub1), NULL, NULL) 133 #define get_cachedir_fname_suffix(sub1, suffix) \ 134 options_get_cachedir_fname2_suffix(get_options(), (sub1), NULL, (suffix)) 136 int using_default_dir_authorities(
const or_options_t *options);
142 const char* str,
const char* descr);
149 #define get_primary_or_port() \ 150 (get_first_advertised_port_by_type_af(CONN_TYPE_OR_LISTENER, AF_INET)) 151 #define get_primary_dir_port() \ 152 (get_first_advertised_port_by_type_af(CONN_TYPE_DIR_LISTENER, AF_INET)) 156 int port,
int check_wildcard);
157 int port_exists_by_type_addr32h_port(
int listener_type, uint32_t addr_ipv4h,
158 int port,
int check_wildcard);
163 const char **reason_out);
168 const char *question,
char **answer,
169 const char **errmsg);
177 int cookie_len,
int group_readable,
178 uint8_t **cookie_out,
int *cookie_is_set_out);
196 const char **rest_out);
202 char *transport_name;
210 #define bridge_line_free(line) \ 211 FREE_AND_NULL(bridge_line_t, bridge_line_free_, (line)) 214 const char *transport);
220 #ifdef CONFIG_PRIVATE 222 #define CL_PORT_NO_STREAM_OPTIONS (1u<<0) 223 #define CL_PORT_WARN_NONLOCAL (1u<<1) 225 #define CL_PORT_SERVER_OPTIONS (1u<<3) 226 #define CL_PORT_FORBID_NONLOCAL (1u<<4) 227 #define CL_PORT_TAKES_HOSTNAMES (1u<<5) 228 #define CL_PORT_IS_UNIXSOCKET (1u<<6) 229 #define CL_PORT_DFLT_GROUP_WRITABLE (1u<<7) 232 #ifdef TOR_UNIT_TESTS 237 #define port_cfg_free(port) \ 238 FREE_AND_NULL(port_cfg_t, port_cfg_free_, (port)) 240 #define or_options_free(opt) \ 241 FREE_AND_NULL(or_options_t, or_options_free_, (opt)) 243 STATIC
int options_validate_single_onion(
or_options_t *options,
248 int from_setconf,
char **msg);
250 const char *line,
int validate_only,
255 MOCK_DECL(STATIC
void, add_default_fallback_dir_servers, (
void));
261 size_t total_mem,
char **msg);
264 const char *portname,
266 const char *defaultaddr,
268 const unsigned flags);
272 STATIC uint64_t compute_real_max_mem_in_queues(
const uint64_t val,
smartlist_t * get_options_for_server_transport(const char *transport)
Definition: config.c:6300
const char * escaped_safe_str_client(const char *address)
Definition: config.c:1065
void bridge_line_free_(bridge_line_t *bridge_line)
Definition: config.c:5827
char * get_transport_bindaddr_from_config(const char *transport)
Definition: config.c:6280
int resolve_my_address(int warn_severity, const or_options_t *options, uint32_t *addr_out, const char **method_out, char **hostname_out)
Definition: config.c:2733
Definition: confline.h:23
#define DIGEST_LEN
Definition: crypto_digest.h:22
or_options_t * options_new(void)
Definition: config.c:2957
int getinfo_helper_config(control_connection_t *conn, const char *question, char **answer, const char **errmsg)
Definition: config.c:8118
int options_init_from_torrc(int argc, char **argv)
Definition: config.c:5152
int options_need_geoip_info(const or_options_t *options, const char **reason_out)
Definition: config.c:1664
STATIC void port_cfg_free_(port_cfg_t *port)
Definition: config.c:6593
setopt_err_t
Definition: or.h:4963
int get_protocol_warning_severity_level(void)
Definition: config.c:1098
STATIC int parse_transport_line(const or_options_t *options, const char *line, int validate_only, int server)
Definition: config.c:5971
MOCK_DECL(int, router_have_minimum_dir_info,(void))
const char * safe_str_client(const char *address)
Definition: config.c:1035
addressmap_entry_source_t
Definition: or.h:4974
int create_keys_directory(const or_options_t *options)
Definition: config.c:1340
STATIC int parse_port_config(smartlist_t *out, const config_line_t *ports, const char *portname, int listener_type, const char *defaultaddr, int defaultport, const unsigned flags)
Definition: config.c:6839
Definition: container.h:18
dirinfo_type_t
Definition: or.h:2879
smartlist_t * get_options_from_transport_options_line(const char *line, const char *transport)
Definition: config.c:6227
void reset_last_resolved_addr(void)
Definition: config.c:2671
STATIC port_cfg_t * port_cfg_new(size_t namelen)
Definition: config.c:6579
const char * option_get_canonical_name(const char *key)
Definition: config.c:2555
char * options_dump(const or_options_t *options, int how_to_dump)
Definition: config.c:2975
const char * safe_str(const char *address)
Definition: config.c:1052
STATIC int check_bridge_distribution_setting(const char *bd)
Definition: config.c:6780
int config_parse_commandline(int argc, char **argv, int ignore_errors, config_line_t **result, config_line_t **cmdline_result)
Definition: config.c:2454
STATIC void add_default_trusted_dir_authorities(dirinfo_type_t type)
Definition: config.c:1151
int port_cfg_line_extract_addrport(const char *line, char **addrport_out, int *is_unix_out, const char **rest_out)
Definition: config.c:6700
uint32_t get_last_resolved_addr(void)
Definition: config.c:2664
uint32_t get_effective_bwrate(const or_options_t *options)
Definition: config.c:1691
STATIC int have_enough_mem_for_dircache(const or_options_t *options, size_t total_mem, char **msg)
Definition: config.c:4651
int get_first_advertised_port_by_type_af(int listener_type, int address_family)
Definition: config.c:7672
int init_cookie_authentication(const char *fname, const char *header, int cookie_len, int group_readable, uint8_t **cookie_out, int *cookie_is_set_out)
Definition: config.c:8385
int option_is_recognized(const char *key)
Definition: config.c:2546
smartlist_t * get_list_of_ports_to_forward(void)
Definition: config.c:8080
void config_free_all(void)
Definition: config.c:995
const char * get_version(void)
Definition: config.c:932
int addressmap_register_auto(const char *from, const char *to, time_t expires, addressmap_entry_source_t addrmap_source, const char **msg)
Definition: config.c:5597
setopt_err_t options_trial_assign(config_line_t *list, unsigned flags, char **msg)
Definition: config.c:2579
struct bridge_line_t bridge_line_t
STATIC int options_act(const or_options_t *old_options)
Definition: config.c:1792
config_line_t * option_get_assignment(const or_options_t *options, const char *key)
Definition: config.c:2564
bridge_line_t * parse_bridge_line(const char *line)
Definition: config.c:5853
int consider_adding_dir_servers(const or_options_t *options, const or_options_t *old_options)
Definition: config.c:1232
void options_init(or_options_t *options)
Definition: config.c:2965
STATIC int options_validate(or_options_t *old_options, or_options_t *options, or_options_t *default_options, int from_setconf, char **msg)
Definition: config.c:3331
const char * escaped_safe_str(const char *address)
Definition: config.c:1077
int get_num_cpus(const or_options_t *options)
Definition: config.c:7951
char * get_first_listener_addrport_string(int listener_type)
Definition: config.c:7618
const tor_addr_t * get_first_advertised_addr_by_type_af(int listener_type, int address_family)
Definition: config.c:7694
int parse_dir_fallback_line(const char *line, int validate_only)
Definition: config.c:6473
setopt_err_t options_init_from_string(const char *cf_defaults, const char *cf, int command, const char *command_arg, char **msg)
Definition: config.c:5359
int port_exists_by_type_addr_port(int listener_type, const tor_addr_t *addr, int port, int check_wildcard)
Definition: config.c:7719
int options_save_current(void)
Definition: config.c:7938
const char * get_short_version(void)
Definition: config.c:947
uint32_t get_effective_bwburst(const or_options_t *options)
Definition: config.c:1705
int set_options(or_options_t *new_val, char **msg)
Definition: config.c:857
STATIC void or_options_free_(or_options_t *options)
Definition: config.c:963
const char * get_torrc_fname(int defaults_fname)
Definition: config.c:5537
int options_any_client_port_set(const or_options_t *options)
Definition: config.c:8444
STATIC int parse_dir_authority_line(const char *line, dirinfo_type_t required_type, int validate_only)
Definition: config.c:6323
void init_protocol_warning_severity_level(void)
Definition: config.c:1116
int write_to_data_subdir(const char *subdir, const char *fname, const char *str, const char *descr)
Definition: config.c:8062
void config_register_addressmaps(const or_options_t *options)
Definition: config.c:5551
int check_or_create_data_subdir(const char *subdir)
Definition: config.c:8043