tor  0.4.2.0-alpha-dev
Macros | Enumerations | Functions | Variables
config.c File Reference
#include "core/or/or.h"
#include "app/config/config.h"
#include "app/config/confparse.h"
#include "app/config/statefile.h"
#include "app/main/main.h"
#include "app/main/subsysmgr.h"
#include "core/mainloop/connection.h"
#include "core/mainloop/cpuworker.h"
#include "core/mainloop/mainloop.h"
#include "core/mainloop/netstatus.h"
#include "core/or/channel.h"
#include "core/or/circuitbuild.h"
#include "core/or/circuitlist.h"
#include "core/or/circuitmux.h"
#include "core/or/circuitmux_ewma.h"
#include "core/or/circuitstats.h"
#include "core/or/connection_edge.h"
#include "core/or/connection_or.h"
#include "core/or/dos.h"
#include "core/or/policies.h"
#include "core/or/relay.h"
#include "core/or/scheduler.h"
#include "feature/client/addressmap.h"
#include "feature/client/bridges.h"
#include "feature/client/entrynodes.h"
#include "feature/client/transports.h"
#include "feature/control/control.h"
#include "feature/control/control_auth.h"
#include "feature/control/control_events.h"
#include "feature/dirauth/bwauth.h"
#include "feature/dirauth/guardfraction.h"
#include "feature/dircache/consdiffmgr.h"
#include "feature/dircache/dirserv.h"
#include "feature/dircommon/voting_schedule.h"
#include "feature/hibernate/hibernate.h"
#include "feature/hs/hs_config.h"
#include "feature/nodelist/dirlist.h"
#include "feature/nodelist/networkstatus.h"
#include "feature/nodelist/nickname.h"
#include "feature/nodelist/nodelist.h"
#include "feature/nodelist/routerlist.h"
#include "feature/nodelist/routerset.h"
#include "feature/relay/dns.h"
#include "feature/relay/ext_orport.h"
#include "feature/relay/routermode.h"
#include "feature/rend/rendclient.h"
#include "feature/rend/rendservice.h"
#include "lib/geoip/geoip.h"
#include "feature/stats/geoip_stats.h"
#include "feature/stats/predict_ports.h"
#include "feature/stats/rephist.h"
#include "lib/compress/compress.h"
#include "lib/confmgt/structvar.h"
#include "lib/crypt_ops/crypto_init.h"
#include "lib/crypt_ops/crypto_rand.h"
#include "lib/crypt_ops/crypto_util.h"
#include "lib/encoding/confline.h"
#include "lib/net/resolve.h"
#include "lib/sandbox/sandbox.h"
#include "lib/version/torversion.h"
#include "lib/crypt_ops/crypto_openssl_mgt.h"
#include "lib/meminfo/meminfo.h"
#include "lib/osinfo/uname.h"
#include "lib/process/daemon.h"
#include "lib/process/pidfile.h"
#include "lib/process/restrict.h"
#include "lib/process/setuid.h"
#include "lib/process/process.h"
#include "lib/net/gethostname.h"
#include "lib/thread/numcpus.h"
#include "lib/encoding/keyval.h"
#include "lib/fs/conffile.h"
#include "lib/evloop/procmon.h"
#include "feature/dirauth/dirvote.h"
#include "feature/dirauth/dirauth_periodic.h"
#include "feature/dirauth/recommend_pkg.h"
#include "feature/dirauth/authmode.h"
#include "core/or/connection_st.h"
#include "core/or/port_cfg_st.h"
#include "auth_dirs.inc"
#include "fallback_dirs.inc"

Go to the source code of this file.

Macros

#define CONFIG_PRIVATE
 
#define MIN_CONSTRAINED_TCP_BUFFER   2048
 
#define MAX_CONSTRAINED_TCP_BUFFER   262144 /* 256k */
 
#define DOWNLOAD_SCHEDULE(name)   { #name "DownloadSchedule", #name "DownloadInitialDelay", 0, 1 }
 
#define VAR(varname, conftype, member, initvalue)
 
#define DUMMY_TEST_MEMBERS
 
#define VAR_D(varname, conftype, member, initvalue)
 
#define V(member, conftype, initvalue)   VAR(#member, conftype, member, initvalue)
 
#define V_D(member, type, initvalue)   VAR_D(#member, type, member, initvalue)
 
#define OBSOLETE(varname)
 
#define VPORT(member)
 
#define UINT64_MAX_STRING   "18446744073709551615"
 
#define OR_OPTIONS_MAGIC   9090909
 
#define YES_IF_CHANGED_BOOL(opt)   if (!CFG_EQ_BOOL(old_options, new_options, opt)) return 1;
 
#define YES_IF_CHANGED_INT(opt)   if (!CFG_EQ_INT(old_options, new_options, opt)) return 1;
 
#define YES_IF_CHANGED_STRING(opt)   if (!CFG_EQ_STRING(old_options, new_options, opt)) return 1;
 
#define YES_IF_CHANGED_LINELIST(opt)   if (!CFG_EQ_LINELIST(old_options, new_options, opt)) return 1;
 
#define YES_IF_CHANGED_SMARTLIST(opt)   if (!CFG_EQ_SMARTLIST(old_options, new_options, opt)) return 1;
 
#define YES_IF_CHANGED_ROUTERSET(opt)   if (!CFG_EQ_ROUTERSET(old_options, new_options, opt)) return 1;
 
#define RELAY_BRIDGE_STATS_DELAY   (6 * 60 * 60)
 
#define MIN_REND_POST_PERIOD   (10*60)
 
#define MIN_REND_POST_PERIOD_TESTING   (5)
 
#define MAX_CIRCS_AVAILABLE_TIME   (24*60*60)
 
#define MAX_DIR_PERIOD   ((7*24*60*60)/2)
 
#define MIN_MAX_CIRCUIT_DIRTINESS   10
 
#define MAX_MAX_CIRCUIT_DIRTINESS   (30*24*60*60)
 
#define MIN_CIRCUIT_STREAM_TIMEOUT   10
 
#define RECOMMENDED_MIN_CIRCUIT_BUILD_TIMEOUT   (10)
 
#define REJECT(arg)   STMT_BEGIN *msg = tor_strdup(arg); return -1; STMT_END
 
#define COMPLAIN(args, ...)   STMT_BEGIN log_warn(LD_CONFIG, args, ##__VA_ARGS__); STMT_END
 
#define CHECK_DEFAULT(arg)
 
#define ONE_GIGABYTE   (UINT64_C(1) << 30)
 
#define ONE_MEGABYTE   (UINT64_C(1) << 20)
 
#define RAM_IS_VERY_LARGE(x)   (0)
 
#define DIRCACHE_MIN_MEM_MB   300
 
#define DIRCACHE_MIN_MEM_BYTES   (DIRCACHE_MIN_MEM_MB*ONE_MEGABYTE)
 
#define STRINGIFY(val)   #val
 
#define BAD_CHANGE_TO(opt, how)
 
#define NO_CHANGE_BOOL(opt)   if (! CFG_EQ_BOOL(old, new_val, opt)) BAD_CHANGE_TO(opt,"")
 
#define NO_CHANGE_INT(opt)   if (! CFG_EQ_INT(old, new_val, opt)) BAD_CHANGE_TO(opt,"")
 
#define NO_CHANGE_STRING(opt)   if (! CFG_EQ_STRING(old, new_val, opt)) BAD_CHANGE_TO(opt,"")
 
#define SB_NOCHANGE_STR(opt)
 
#define SB_NOCHANGE_LINELIST(opt)
 
#define SB_NOCHANGE_INT(opt)
 
#define GENERATED_FILE_PREFIX
 
#define GENERATED_FILE_COMMENT
 

Enumerations

enum  takes_argument_t { TAKES_NO_ARGUMENT = 0, ARGUMENT_NECESSARY = 1, ARGUMENT_OPTIONAL = 2 }
 

Functions

 DUMMY_TYPECHECK_INSTANCE (or_options_t)
 
static int options_act_reversible (const or_options_t *old_options, char **msg)
 
static int options_transition_allowed (const or_options_t *old, const or_options_t *new, char **msg)
 
static int options_transition_affects_workers (const or_options_t *old_options, const or_options_t *new_options)
 
static int options_transition_affects_descriptor (const or_options_t *old_options, const or_options_t *new_options)
 
static int options_transition_affects_dirauth_timing (const or_options_t *old_options, const or_options_t *new_options)
 
static int normalize_nickname_list (config_line_t **normalized_out, const config_line_t *lst, const char *name, char **msg)
 
static char * get_bindaddr_from_transport_listen_line (const char *line, const char *transport)
 
static int parse_ports (or_options_t *options, int validate_only, char **msg_out, int *n_ports_out, int *world_writable_control_socket)
 
static int check_server_ports (const smartlist_t *ports, const or_options_t *options, int *num_low_ports_out)
 
static int validate_data_directories (or_options_t *options)
 
static int write_configuration_file (const char *fname, const or_options_t *options)
 
static int options_init_logs (const or_options_t *old_options, or_options_t *options, int validate_only)
 
static void init_libevent (const or_options_t *options)
 
static int opt_streq (const char *s1, const char *s2)
 
static int parse_outbound_addresses (or_options_t *options, int validate_only, char **msg)
 
static void config_maybe_load_geoip_files_ (const or_options_t *options, const or_options_t *old_options)
 
static int options_validate_cb (void *old_options, void *options, void *default_options, int from_setconf, char **msg)
 
static void options_free_cb (void *options)
 
static void cleanup_protocol_warning_severity_level (void)
 
static void set_protocol_warning_severity_level (int warning_severity)
 
 MOCK_IMPL (const char *, get_dirportfrontpage,(void))
 
 MOCK_IMPL (or_options_t *, get_options_mutable,(void))
 
 MOCK_IMPL (const or_options_t *, get_options,(void))
 
int set_options (or_options_t *new_val, char **msg)
 
STATIC void or_options_free_ (or_options_t *options)
 
void config_free_all (void)
 
const char * safe_str_client_opts (const or_options_t *options, const char *address)
 
const char * safe_str_opts (const or_options_t *options, const char *address)
 
const char * escaped_safe_str_client (const char *address)
 
const char * escaped_safe_str (const char *address)
 
int get_protocol_warning_severity_level (void)
 
void init_protocol_warning_severity_level (void)
 
STATIC void add_default_trusted_dir_authorities (dirinfo_type_t type)
 
 MOCK_IMPL (void, add_default_fallback_dir_servers,(void))
 
static int validate_dir_servers (or_options_t *options, or_options_t *old_options)
 
int consider_adding_dir_servers (const or_options_t *options, const or_options_t *old_options)
 
static int check_and_create_data_directory (int create, const char *directory, int group_readable, const char *owner, char **msg_out)
 
int create_keys_directory (const or_options_t *options)
 
int options_need_geoip_info (const or_options_t *options, const char **reason_out)
 
uint32_t get_effective_bwrate (const or_options_t *options)
 
uint32_t get_effective_bwburst (const or_options_t *options)
 
static int options_transition_affects_guards (const or_options_t *old_options, const or_options_t *new_options)
 
STATIC int options_act (const or_options_t *old_options)
 
int config_parse_commandline (int argc, char **argv, int ignore_errors, config_line_t **result, config_line_t **cmdline_result)
 
int option_is_recognized (const char *key)
 
const char * option_get_canonical_name (const char *key)
 
config_line_toption_get_assignment (const or_options_t *options, const char *key)
 
setopt_err_t options_trial_assign (config_line_t *list, unsigned flags, char **msg)
 
static void print_usage (void)
 
static void list_torrc_options (void)
 
static void list_deprecated_options (void)
 
static void list_enabled_modules (void)
 
uint32_t get_last_resolved_addr (void)
 
void reset_last_resolved_addr (void)
 
int using_default_dir_authorities (const or_options_t *options)
 
int resolve_my_address (int warn_severity, const or_options_t *options, uint32_t *addr_out, const char **method_out, char **hostname_out)
 
 MOCK_IMPL (int, is_local_addr,(const tor_addr_t *addr))
 
or_options_toptions_new (void)
 
void options_init (or_options_t *options)
 
char * options_dump (const or_options_t *options, int how_to_dump)
 
static int validate_ports_csv (smartlist_t *sl, const char *name, char **msg)
 
static int ensure_bandwidth_cap (uint64_t *value, const char *desc, char **msg)
 
static int compute_publishserverdescriptor (or_options_t *options)
 
static int warn_if_option_path_is_relative (const char *option, char *filepath)
 
static int warn_about_relative_paths (or_options_t *options)
 
static int options_validate_scheduler (or_options_t *options, char **msg)
 
STATIC int options_validate_single_onion (or_options_t *options, char **msg)
 
STATIC int options_validate (or_options_t *old_options, or_options_t *options, or_options_t *default_options, int from_setconf, char **msg)
 
STATIC uint64_t compute_real_max_mem_in_queues (const uint64_t val, int log_guess)
 
STATIC int have_enough_mem_for_dircache (const or_options_t *options, size_t total_mem, char **msg)
 
static const char * get_default_conf_file (int defaults_file)
 
static char * find_torrc_filename (config_line_t *cmd_arg, int defaults_file, int *using_default_fname, int *ignore_missing_torrc)
 
static char * load_torrc_from_stdin (void)
 
static char * load_torrc_from_disk (config_line_t *cmd_arg, int defaults_file)
 
int options_init_from_torrc (int argc, char **argv)
 
setopt_err_t options_init_from_string (const char *cf_defaults, const char *cf, int command, const char *command_arg, char **msg)
 
const char * get_torrc_fname (int defaults_fname)
 
void config_register_addressmaps (const or_options_t *options)
 
int addressmap_register_auto (const char *from, const char *to, time_t expires, addressmap_entry_source_t addrmap_source, const char **msg)
 
STATIC int open_and_add_file_log (const log_severity_list_t *severity, const char *filename, int truncate_log)
 
static int validate_transport_socks_arguments (const smartlist_t *args)
 
void bridge_line_free_ (bridge_line_t *bridge_line)
 
bridge_line_tparse_bridge_line (const char *line)
 
STATIC int parse_transport_line (const or_options_t *options, const char *line, int validate_only, int server)
 
smartlist_tget_options_from_transport_options_line (const char *line, const char *transport)
 
char * get_transport_bindaddr_from_config (const char *transport)
 
smartlist_tget_options_for_server_transport (const char *transport)
 
STATIC int parse_dir_authority_line (const char *line, dirinfo_type_t required_type, int validate_only)
 
int parse_dir_fallback_line (const char *line, int validate_only)
 
STATIC port_cfg_tport_cfg_new (size_t namelen)
 
STATIC void port_cfg_free_ (port_cfg_t *port)
 
static void warn_nonlocal_client_ports (const smartlist_t *ports, const char *portname, const int listener_type)
 
static void warn_nonlocal_ext_orports (const smartlist_t *ports, const char *portname)
 
static void warn_nonlocal_controller_ports (smartlist_t *ports, unsigned forbid_nonlocal)
 
int port_cfg_line_extract_addrport (const char *line, char **addrport_out, int *is_unix_out, const char **rest_out)
 
static void warn_client_dns_cache (const char *option, int disabling)
 
STATIC int check_bridge_distribution_setting (const char *bd)
 
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)
 
static int count_real_listeners (const smartlist_t *ports, int listenertype, int count_sockets)
 
static int port_binds_ipv4 (const port_cfg_t *port)
 
static int port_binds_ipv6 (const port_cfg_t *port)
 
 MOCK_IMPL (const smartlist_t *, get_configured_ports,(void))
 
char * get_first_listener_addrport_string (int listener_type)
 
int get_first_advertised_port_by_type_af (int listener_type, int address_family)
 
const tor_addr_tget_first_advertised_addr_by_type_af (int listener_type, int address_family)
 
int port_exists_by_type_addr_port (int listener_type, const tor_addr_t *addr, int port, int check_wildcard)
 
int port_exists_by_type_addr32h_port (int listener_type, uint32_t addr_ipv4h, int port, int check_wildcard)
 
static char * get_data_directory (const char *val)
 
int options_save_current (void)
 
int get_num_cpus (const or_options_t *options)
 
 MOCK_IMPL (char *, options_get_dir_fname2_suffix,(const or_options_t *options, directory_root_t roottype, const char *sub1, const char *sub2, const char *suffix))
 
int check_or_create_data_subdir (const char *subdir)
 
int write_to_data_subdir (const char *subdir, const char *fname, const char *str, const char *descr)
 
smartlist_tget_list_of_ports_to_forward (void)
 
int getinfo_helper_config (control_connection_t *conn, const char *question, char **answer, const char **errmsg)
 
static int verify_and_store_outbound_address (sa_family_t family, tor_addr_t *addr, outbound_addr_t type, or_options_t *options, int validate_only)
 
static int parse_outbound_address_lines (const config_line_t *lines, outbound_addr_t type, or_options_t *options, int validate_only, char **msg)
 
static void config_load_geoip_file_ (sa_family_t family, const char *fname, const char *default_fname)
 
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)
 
int options_any_client_port_set (const or_options_t *options)
 

Variables

static const char unix_socket_prefix [] = "unix:"
 
static const char unix_q_socket_prefix [] = "unix:\""
 
static config_abbrev_t option_abbrevs_ []
 
static config_var_t option_vars_ []
 
static const config_var_t testing_tor_network_defaults []
 
static const config_deprecation_t option_deprecation_notes_ []
 
STATIC config_format_t options_format
 
static or_options_tglobal_options = NULL
 
static or_options_tglobal_default_options = NULL
 
static char * torrc_fname = NULL
 
static char * torrc_defaults_fname = NULL
 
static config_line_tglobal_cmdline_options = NULL
 
static config_line_tglobal_cmdline_only_options = NULL
 
static int have_parsed_cmdline = 0
 
static char * global_dirfrontpagecontents = NULL
 
static smartlist_tconfigured_ports = NULL
 
static int in_option_validation = 0
 
static int libevent_initialized = 0
 
static atomic_counter_t protocol_warning_severity_level
 
static const char * default_authorities []
 
static const char * default_fallbacks []
 
static int have_low_ports = -1
 
struct {
   const char *   name
 
   takes_argument_t   takes_argument
 
CMDLINE_ONLY_OPTIONS []
 
static uint32_t last_resolved_addr = 0
 

Detailed Description

Code to interpret the user's configuration of Tor.

This module handles torrc configuration file, including parsing it, combining it with torrc.defaults and the command line, allowing user changes to it (via editing and SIGHUP or via the control port), writing it back to disk (because of SAVECONF from the control port), and – most importantly, acting on it.

The module additionally has some tools for manipulating and inspecting values that are calculated as a result of the configured options.

How to add new options

To add new items to the torrc, there are a minimum of three places to edit:

Additionally, you might need to edit these places too:

Changing the value of an option

Because of the SAVECONF command from the control port, it's a bad idea to change the value of any user-configured option in the or_options_t. If you want to sometimes do this anyway, we recommend that you create a secondary field in or_options_t; that you have the user option linked only to the secondary field; that you use the secondary field to initialize the one that Tor actually looks at; and that you use the one Tor looks as the one that you modify.

Definition in file config.c.

Macro Definition Documentation

◆ BAD_CHANGE_TO

#define BAD_CHANGE_TO (   opt,
  how 
)
Value:
do { \
*msg = tor_strdup("While Tor is running"how", changing " #opt \
" is not allowed"); \
return -1; \
} while (0)

◆ CHECK_DEFAULT

#define CHECK_DEFAULT (   arg)
Value:
STMT_BEGIN \
if (!options->TestingTorNetwork && \
!options->UsingTestNetworkDefaults_ && \
default_options,#arg)) { \
REJECT(#arg " may only be changed in testing Tor " \
"networks!"); \
} STMT_END
STATIC config_format_t options_format
Definition: config.c:879
int config_is_same(const config_format_t *fmt, const void *o1, const void *o2, const char *name)
Definition: confparse.c:541

◆ DOWNLOAD_SCHEDULE

#define DOWNLOAD_SCHEDULE (   name)    { #name "DownloadSchedule", #name "DownloadInitialDelay", 0, 1 }

macro to help with the bulk rename of *DownloadSchedule to *DowloadInitialDelay .

Definition at line 189 of file config.c.

◆ GENERATED_FILE_COMMENT

#define GENERATED_FILE_COMMENT
Value:
"# The old torrc file was renamed " \
"to torrc.orig.1 or similar, and Tor will ignore it"

This string can change; it tries to give the reader an idea that editing this file by hand is not a good plan.

Definition at line 7925 of file config.c.

◆ GENERATED_FILE_PREFIX

#define GENERATED_FILE_PREFIX
Value:
"# This file was generated by Tor; " \
"if you edit it, comments will not be preserved"

This string must remain the same forevermore. It is how we recognize that the torrc file doesn't need to be backed up.

Definition at line 7921 of file config.c.

◆ MAX_CIRCS_AVAILABLE_TIME

#define MAX_CIRCS_AVAILABLE_TIME   (24*60*60)

Highest allowable value for CircuitsAvailableTimeout. If this is too large, client connections will stay open for too long, incurring extra padding overhead.

Definition at line 3143 of file config.c.

◆ MAX_DIR_PERIOD

#define MAX_DIR_PERIOD   ((7*24*60*60)/2)

Highest allowable value for RendPostPeriod.

Definition at line 3146 of file config.c.

◆ MAX_MAX_CIRCUIT_DIRTINESS

#define MAX_MAX_CIRCUIT_DIRTINESS   (30*24*60*60)

Highest allowable value for MaxCircuitDirtiness: prevents time_t overflows.

Definition at line 3154 of file config.c.

◆ MIN_CIRCUIT_STREAM_TIMEOUT

#define MIN_CIRCUIT_STREAM_TIMEOUT   10

Lowest allowable value for CircuitStreamTimeout; if this is too low, Tor will generate too many circuits and potentially overload the network.

Definition at line 3158 of file config.c.

◆ MIN_MAX_CIRCUIT_DIRTINESS

#define MIN_MAX_CIRCUIT_DIRTINESS   10

Lowest allowable value for MaxCircuitDirtiness; if this is too low, Tor will generate too many circuits and potentially overload the network.

Definition at line 3150 of file config.c.

◆ MIN_REND_POST_PERIOD

#define MIN_REND_POST_PERIOD   (10*60)

Lowest allowable value for RendPostPeriod; if this is too low, hidden services can overload the directory system.

Definition at line 3137 of file config.c.

◆ OBSOLETE

#define OBSOLETE (   varname)
Value:
{ { .name = varname, .type = CONFIG_TYPE_OBSOLETE, }, NULL \
DUMMY_TEST_MEMBERS }

An entry for config_vars: "The option <b>varname</b> is obsolete."

Definition at line 292 of file config.c.

◆ OR_OPTIONS_MAGIC

#define OR_OPTIONS_MAGIC   9090909

Magic value for or_options_t.

Definition at line 876 of file config.c.

◆ RECOMMENDED_MIN_CIRCUIT_BUILD_TIMEOUT

#define RECOMMENDED_MIN_CIRCUIT_BUILD_TIMEOUT   (10)

Lowest recommended value for CircuitBuildTimeout; if it is set too low and LearnCircuitBuildTimeout is off, the failure rate for circuit construction may be very high. In that case, if it is set below this threshold emit a warning.

Definition at line 3165 of file config.c.

◆ SB_NOCHANGE_INT

#define SB_NOCHANGE_INT (   opt)
Value:
if (! CFG_EQ_INT(old, new_val, opt)) \
BAD_CHANGE_TO(opt," with Sandbox active")

◆ SB_NOCHANGE_LINELIST

#define SB_NOCHANGE_LINELIST (   opt)
Value:
if (! CFG_EQ_LINELIST(old, new_val, opt)) \
BAD_CHANGE_TO(opt," with Sandbox active")

◆ SB_NOCHANGE_STR

#define SB_NOCHANGE_STR (   opt)
Value:
if (! CFG_EQ_STRING(old, new_val, opt)) \
BAD_CHANGE_TO(opt," with Sandbox active")

◆ UINT64_MAX_STRING

#define UINT64_MAX_STRING   "18446744073709551615"

UINT64_MAX as a decimal string

Definition at line 309 of file config.c.

◆ V

#define V (   member,
  conftype,
  initvalue 
)    VAR(#member, conftype, member, initvalue)

As VAR, but the option name and member name are the same.

Definition at line 284 of file config.c.

◆ V_D

#define V_D (   member,
  type,
  initvalue 
)    VAR_D(#member, type, member, initvalue)

As V, but uses a type definition instead of a type enum

Definition at line 288 of file config.c.

◆ VAR

#define VAR (   varname,
  conftype,
  member,
  initvalue 
)
Value:
{ { .name = varname, \
.type = CONFIG_TYPE_ ## conftype, \
.offset = offsetof(or_options_t, member), \
}, \
initvalue CONF_TEST_MEMBERS(or_options_t, conftype, member) }

An entry for config_vars: "The option varname has type CONFIG_TYPE_conftype, and corresponds to or_options_t.member"

Definition at line 261 of file config.c.

◆ VAR_D

#define VAR_D (   varname,
  conftype,
  member,
  initvalue 
)
Value:
{ { .name = varname, \
.type = CONFIG_TYPE_ ## conftype, \
.type_def = &conftype ## _type_defn, \
.offset = offsetof(or_options_t, member), \
}, \
initvalue DUMMY_TEST_MEMBERS }

Definition at line 275 of file config.c.

◆ VPORT

#define VPORT (   member)
Value:
VAR(#member "Lines", LINELIST_V, member ## _lines, NULL), \
VAR(#member, LINELIST_S, member ## _lines, NULL), \
VAR("__" #member, LINELIST_S, member ## _lines, NULL)
#define VAR(varname, conftype, member, initvalue)
Definition: config.c:261

Macro to declare *Port options. Each one comes in three entries. For example, most users should use "SocksPort" to configure the socks port, but TorBrowser wants to use __SocksPort so that it isn't stored by SAVECONF. The SocksPortLines virtual option is used to query both options from the controller.

Definition at line 303 of file config.c.

Function Documentation

◆ add_default_trusted_dir_authorities()

STATIC void add_default_trusted_dir_authorities ( dirinfo_type_t  type)

Add the default directory authorities directly into the trusted dir list, but only add them insofar as they share bits with type. Each authority's bits are restricted to the bits shared with type. If type is ALL_DIRINFO or NO_DIRINFO (zero), add all authorities.

Definition at line 1215 of file config.c.

◆ addressmap_register_auto()

int addressmap_register_auto ( const char *  from,
const char *  to,
time_t  expires,
addressmap_entry_source_t  addrmap_source,
const char **  msg 
)

As addressmap_register(), but detect the wildcarded status of "from" and "to", and do not steal a reference to to.

Definition at line 5640 of file config.c.

References address_is_invalid_destination(), and addressmap_register().

◆ bridge_line_free_()

void bridge_line_free_ ( bridge_line_t bridge_line)

Deallocate a bridge_line_t structure.

Definition at line 5887 of file config.c.

References SMARTLIST_FOREACH, and tor_free.

◆ check_and_create_data_directory()

static int check_and_create_data_directory ( int  create,
const char *  directory,
int  group_readable,
const char *  owner,
char **  msg_out 
)
static

Make sure that directory exists, with appropriate ownership and permissions (as modified by group_readable). If create, create the directory if it is missing. Return 0 on success. On failure, return -1 and set *msg_out.

Definition at line 1367 of file config.c.

◆ check_bridge_distribution_setting()

STATIC int check_bridge_distribution_setting ( const char *  bd)

Validate the configured bridge distribution method from a BridgeDistribution config line.

The input bd, is a string taken from the BridgeDistribution config line (if present). If the option wasn't set, return 0 immediately. The BridgeDistribution option is then validated. Currently valid, recognised options are:

  • "none"
  • "any"
  • "https"
  • "email"
  • "moat"
  • "hyphae"

If the option string is unrecognised, a warning will be logged and 0 is returned. If the option string contains an invalid character, -1 is returned.

Definition at line 6848 of file config.c.

References ARRAY_LENGTH.

◆ check_or_create_data_subdir()

int check_or_create_data_subdir ( const char *  subdir)

Check wether the data directory has a private subdirectory subdir. If not, try to create it. Return 0 on success, -1 otherwise.

Definition at line 8113 of file config.c.

◆ check_server_ports()

static int check_server_ports ( const smartlist_t ports,
const or_options_t options,
int *  n_low_ports_out 
)
static

Given a list of port_cfg_t in ports, check them for internal consistency and warn as appropriate. Set *n_low_ports_out to the number of sub-1024 ports we will be binding.

Definition at line 7584 of file config.c.

References CONN_TYPE_DIR_LISTENER, CONN_TYPE_OR_LISTENER, and SMARTLIST_FOREACH_BEGIN.

◆ cleanup_protocol_warning_severity_level()

static void cleanup_protocol_warning_severity_level ( void  )
static

Tear down protocol_warning_severity_level.

Definition at line 1190 of file config.c.

References atomic_counter_destroy(), and protocol_warning_severity_level.

◆ compute_publishserverdescriptor()

static int compute_publishserverdescriptor ( or_options_t options)
static

Parse an authority type from options->PublishServerDescriptor and write it to options->PublishServerDescriptor_. Treat "1" as "v3" unless BridgeRelay is 1, in which case treat it as "bridge". Treat "0" as "". Return 0 on success or -1 if not a recognized authority type (in which case the value of PublishServerDescriptor_ is undefined).

Definition at line 3100 of file config.c.

References or_options_t::PublishServerDescriptor, and or_options_t::PublishServerDescriptor_.

◆ config_free_all()

void config_free_all ( void  )

Release all memory and resources held by global configuration structures.

Definition at line 1054 of file config.c.

References global_default_options, and global_options.

◆ config_load_geoip_file_()

static void config_load_geoip_file_ ( sa_family_t  family,
const char *  fname,
const char *  default_fname 
)
static

Load one of the geoip files, family determining which one. default_fname is used if on Windows and fname equals "<default>".

Definition at line 8375 of file config.c.

Referenced by config_maybe_load_geoip_files_().

◆ config_maybe_load_geoip_files_()

static void config_maybe_load_geoip_files_ ( const or_options_t options,
const or_options_t old_options 
)
static

Load geoip files for IPv4 and IPv6 if options and old_options indicate we should.

Definition at line 8408 of file config.c.

References config_load_geoip_file_(), or_options_t::GeoIPFile, opt_streq(), and refresh_all_country_info().

◆ config_parse_commandline()

int config_parse_commandline ( int  argc,
char **  argv,
int  ignore_errors,
config_line_t **  result,
config_line_t **  cmdline_result 
)

Helper: Read a list of configuration options from the command line. If successful, or if ignore_errors is set, put them in *result, put the commandline-only options in *cmdline_result, and return 0; otherwise, return -1 and leave *result and cmdline_result alone.

Definition at line 2496 of file config.c.

References CONFIG_LINE_NORMAL.

Referenced by options_init_from_torrc().

◆ config_register_addressmaps()

void config_register_addressmaps ( const or_options_t options)

Adjust the address map based on the MapAddress elements in the configuration options

Definition at line 5594 of file config.c.

References or_options_t::AddressMap, addressmap_clear_configured(), and smartlist_split_string().

◆ consider_adding_dir_servers()

int consider_adding_dir_servers ( const or_options_t options,
const or_options_t old_options 
)

Look at all the config options and assign new dir authorities as appropriate.

Definition at line 1296 of file config.c.

◆ count_real_listeners()

static int count_real_listeners ( const smartlist_t ports,
int  listenertype,
int  count_sockets 
)
static

Return the number of ports which are actually going to listen with type listenertype. Do not count no_listen ports. Only count unix sockets if count_sockets is true.

Definition at line 7365 of file config.c.

References SMARTLIST_FOREACH_BEGIN.

◆ create_keys_directory()

int create_keys_directory ( const or_options_t options)

Ensure that our keys directory exists, with appropriate permissions. Return 0 on success, -1 on failure.

Definition at line 1404 of file config.c.

◆ DUMMY_TYPECHECK_INSTANCE()

DUMMY_TYPECHECK_INSTANCE ( or_options_t  )

dummy instance of or_options_t, used for type-checking its members with CONF_CHECK_VAR_TYPE.

◆ ensure_bandwidth_cap()

static int ensure_bandwidth_cap ( uint64_t *  value,
const char *  desc,
char **  msg 
)
static

If value exceeds ROUTER_MAX_DECLARED_BANDWIDTH, write a complaint into *msg using string desc, and return -1. Else return 0.

Definition at line 3077 of file config.c.

◆ escaped_safe_str()

const char* escaped_safe_str ( const char *  address)

Equivalent to escaped(safe_str(address)). See reentrancy note on escaped(): don't use this outside the main thread, or twice in the same log statement.

Definition at line 1141 of file config.c.

References escaped().

◆ escaped_safe_str_client()

const char* escaped_safe_str_client ( const char *  address)

Equivalent to escaped(safe_str_client(address)). See reentrancy note on escaped(): don't use this outside the main thread, or twice in the same log statement.

Definition at line 1129 of file config.c.

References escaped().

◆ find_torrc_filename()

static char* find_torrc_filename ( config_line_t cmd_arg,
int  defaults_file,
int *  using_default_fname,
int *  ignore_missing_torrc 
)
static

Learn config file name from command line arguments, or use the default.

If defaults_file is true, we're looking for torrc-defaults; otherwise, we're looking for the regular torrc_file.

Set *using_default_fname to true if we're using the default configuration file name; or false if we've set it from the command line.

Set *ignore_missing_torrc to true if we should ignore the resulting filename if it doesn't exist.

Definition at line 5047 of file config.c.

Referenced by load_torrc_from_disk().

◆ get_bindaddr_from_transport_listen_line()

static char * get_bindaddr_from_transport_listen_line ( const char *  line,
const char *  transport 
)
static

Given a ServerTransportListenAddr line, return its <address:port> string. Return NULL if the line was not well-formed.

If transport is set, return NULL if the line is not referring to transport.

The returned string is allocated on the heap and it's the responsibility of the caller to free it.

Definition at line 6234 of file config.c.

References smartlist_split_string().

Referenced by get_transport_bindaddr_from_config().

◆ get_data_directory()

static char* get_data_directory ( const char *  val)
static

Allocate and return a good value for the DataDirectory based on val, which may be NULL. Return NULL on failure.

Definition at line 7844 of file config.c.

Referenced by validate_data_directories().

◆ get_default_conf_file()

static const char* get_default_conf_file ( int  defaults_file)
static

Return the default location for our torrc file (if defaults_file is false), or for the torrc-defaults file (if defaults_file is true).

Definition at line 4934 of file config.c.

References tor_snprintf().

Referenced by get_torrc_fname().

◆ get_effective_bwburst()

uint32_t get_effective_bwburst ( const or_options_t options)

Return the bandwidthburst that we are going to report to the authorities based on the config options.

Definition at line 1775 of file config.c.

References or_options_t::BandwidthBurst, and or_options_t::RelayBandwidthBurst.

◆ get_effective_bwrate()

uint32_t get_effective_bwrate ( const or_options_t options)

Return the bandwidthrate that we are going to report to the authorities based on the config options.

Definition at line 1761 of file config.c.

References or_options_t::BandwidthRate, or_options_t::MaxAdvertisedBandwidth, and or_options_t::RelayBandwidthRate.

Referenced by router_should_be_dirserver().

◆ get_first_advertised_addr_by_type_af()

const tor_addr_t* get_first_advertised_addr_by_type_af ( int  listener_type,
int  address_family 
)

Return the first advertised address of type listener_type in address_family. Returns NULL if there is no advertised address, and when passed AF_UNSPEC.

Definition at line 7764 of file config.c.

References configured_ports, and SMARTLIST_FOREACH_BEGIN.

◆ get_first_advertised_port_by_type_af()

int get_first_advertised_port_by_type_af ( int  listener_type,
int  address_family 
)

Return the first advertised port of type listener_type in address_family. Returns 0 when no port is found, and when passed AF_UNSPEC.

Definition at line 7742 of file config.c.

References SMARTLIST_FOREACH_BEGIN.

Referenced by router_get_advertised_or_port_by_af().

◆ get_first_listener_addrport_string()

char* get_first_listener_addrport_string ( int  listener_type)

Return an address:port string representation of the address where the first listener_type listener waits for connections. Return NULL if we couldn't find a listener. The string is allocated on the heap and it's the responsibility of the caller to free it after use.

This function is meant to be used by the pluggable transport proxy spawning code, please make sure that it fits your purposes before using it.

Definition at line 7688 of file config.c.

References CFG_AUTO_PORT, configured_ports, fmt_and_decorate_addr, router_get_active_listener_port_by_type_af(), SMARTLIST_FOREACH_BEGIN, tor_addr_family(), tor_addr_is_null(), tor_addr_is_v4(), and tor_asprintf().

◆ get_last_resolved_addr()

uint32_t get_last_resolved_addr ( void  )

Accessor for last_resolved_addr from outside this file.

Definition at line 2713 of file config.c.

References last_resolved_addr.

Referenced by MOCK_IMPL().

◆ get_list_of_ports_to_forward()

smartlist_t* get_list_of_ports_to_forward ( void  )

Return a smartlist of ports that must be forwarded by tor-fw-helper. The smartlist contains the ports in a string format that is understandable by tor-fw-helper.

XXX TODO tor-fw-helper does not support forwarding ports to other hosts than the local one. If the user is binding to a different IP address, tor-fw-helper won't work.

Definition at line 8150 of file config.c.

References get_transport_proxy_ports(), router_get_advertised_dir_port(), router_get_advertised_or_port(), smartlist_add_all(), and smartlist_add_asprintf().

◆ get_num_cpus()

int get_num_cpus ( const or_options_t options)

Return the number of cpus configured in options. If we are told to auto-detect the number of cpus, return the auto-detected number.

Definition at line 8021 of file config.c.

References compute_num_cpus(), and or_options_t::NumCPUs.

Referenced by init_libevent().

◆ get_options_for_server_transport()

smartlist_t* get_options_for_server_transport ( const char *  transport)

Given the name of a pluggable transport in transport, check the configuration file to see if the user has asked us to pass any parameters to the pluggable transport. Return a smartlist containing the parameters, otherwise NULL.

Definition at line 6360 of file config.c.

References get_options_from_transport_options_line(), and or_options_t::ServerTransportOptions.

Referenced by get_transport_options_for_server_proxy().

◆ get_options_from_transport_options_line()

smartlist_t* get_options_from_transport_options_line ( const char *  line,
const char *  transport 
)

Given a ServerTransportOptions line, return a smartlist with the options. Return NULL if the line was not well-formed.

If transport is set, return NULL if the line is not referring to transport.

The returned smartlist and its strings are allocated on the heap and it's the responsibility of the caller to free it.

Definition at line 6287 of file config.c.

References smartlist_split_string().

Referenced by get_options_for_server_transport().

◆ get_protocol_warning_severity_level()

int get_protocol_warning_severity_level ( void  )

Return the severity level that should be used for warnings of severity LOG_PROTOCOL_WARN.

Definition at line 1162 of file config.c.

References atomic_counter_get(), and protocol_warning_severity_level.

◆ get_torrc_fname()

const char* get_torrc_fname ( int  defaults_fname)

Return the location for our configuration file. May return NULL.

Definition at line 5580 of file config.c.

References get_default_conf_file(), torrc_defaults_fname, and torrc_fname.

Referenced by options_save_current().

◆ get_transport_bindaddr_from_config()

char* get_transport_bindaddr_from_config ( const char *  transport)

Given the name of a pluggable transport in transport, check the configuration file to see if the user has explicitly asked for it to listen on a specific port. Return a <address:port> string if so, otherwise NULL.

Definition at line 6340 of file config.c.

References get_bindaddr_from_transport_listen_line(), and or_options_t::ServerTransportListenAddr.

Referenced by get_stored_bindaddr_for_server_transport().

◆ getinfo_helper_config()

int getinfo_helper_config ( control_connection_t conn,
const char *  question,
char **  answer,
const char **  errmsg 
)

Helper to implement GETINFO functions about configuration variables (not their values). Given a "config/names" question, set *answer to a new string describing the supported configuration variables and their types.

Definition at line 8188 of file config.c.

References struct_member_t::name, and option_vars_.

◆ have_enough_mem_for_dircache()

STATIC int have_enough_mem_for_dircache ( const or_options_t options,
size_t  total_mem,
char **  msg 
)

Create a warning message for emitting if we are a dircache but may not have enough system memory, or if we are not a dircache but probably should be. Return -1 when a message is returned in msg, else return 0.

Definition at line 4683 of file config.c.

References or_options_t::DirCache, and or_options_t::MaxMemInQueues.

◆ init_cookie_authentication()

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 
)

Initialize cookie authentication (used so far by the ControlPort and Extended ORPort).

Allocate memory and create a cookie (of length cookie_len) in cookie_out. Then write it down to fname and prepend it with header.

If group_readable is set, set fname to be readable by the default GID.

If the whole procedure was successful, set cookie_is_set_out to True.

Definition at line 8444 of file config.c.

◆ init_libevent()

static void init_libevent ( const or_options_t options)
static

◆ init_protocol_warning_severity_level()

void init_protocol_warning_severity_level ( void  )

Initialize the log warning severity level for protocol warnings. Call only once at startup.

Definition at line 1180 of file config.c.

References atomic_counter_init(), LOG_WARN, protocol_warning_severity_level, and set_protocol_warning_severity_level().

Referenced by tor_run_main().

◆ list_deprecated_options()

static void list_deprecated_options ( void  )
static

Print all deprecated but non-obsolete torrc options.

Definition at line 2693 of file config.c.

Referenced by options_init_from_torrc().

◆ list_enabled_modules()

static void list_enabled_modules ( void  )
static

Print all compile-time modules and their enabled/disabled status.

Definition at line 2703 of file config.c.

Referenced by options_init_from_torrc().

◆ list_torrc_options()

static void list_torrc_options ( void  )
static

Print all non-obsolete torrc options.

Definition at line 2679 of file config.c.

References CONFIG_TYPE_LINELIST_V, CONFIG_TYPE_OBSOLETE, struct_member_t::name, option_vars_, and struct_member_t::type.

Referenced by options_init_from_torrc().

◆ load_torrc_from_disk()

static char* load_torrc_from_disk ( config_line_t cmd_arg,
int  defaults_file 
)
static

Load a configuration file from disk, setting torrc_fname or torrc_defaults_fname if successful.

If defaults_file is true, load torrc-defaults; otherwise load torrc.

Return the contents of the file on success, and NULL on failure.

Definition at line 5131 of file config.c.

References find_torrc_filename(), tor_free, torrc_defaults_fname, and torrc_fname.

◆ load_torrc_from_stdin()

static char* load_torrc_from_stdin ( void  )
static

Read the torrc from standard input and return it as a string. Upon failure, return NULL.

Definition at line 5116 of file config.c.

References read_file_to_str_until_eof().

◆ MOCK_IMPL() [1/7]

MOCK_IMPL ( const char *  ,
get_dirportfrontpage  ,
(void)   
)

Return the contents of our frontpage string, or NULL if not configured.

Definition at line 924 of file config.c.

References global_dirfrontpagecontents.

◆ MOCK_IMPL() [2/7]

MOCK_IMPL ( or_options_t ,
get_options_mutable  ,
(void)   
)

Returns the currently configured options.

Definition at line 931 of file config.c.

References global_options, and tor_assert().

◆ MOCK_IMPL() [3/7]

MOCK_IMPL ( const or_options_t ,
get_options  ,
(void)   
)

Returns the currently configured options

Definition at line 940 of file config.c.

◆ MOCK_IMPL() [4/7]

MOCK_IMPL ( void  ,
add_default_fallback_dir_servers  ,
(void)   
)

Add the default fallback directory servers into the fallback directory server list.

Definition at line 1228 of file config.c.

References default_fallbacks, and parse_dir_fallback_line().

◆ MOCK_IMPL() [5/7]

MOCK_IMPL ( int  ,
is_local_addr  ,
(const tor_addr_t *addr)   
)

Return true iff addr is judged to be on the same network as us, or on a private network.

Definition at line 2979 of file config.c.

◆ MOCK_IMPL() [6/7]

MOCK_IMPL ( const smartlist_t ,
get_configured_ports  ,
(void)   
)

Return a list of port_cfg_t for client ports parsed from the options.

Definition at line 7670 of file config.c.

References configured_ports.

◆ MOCK_IMPL() [7/7]

MOCK_IMPL ( char *  ,
options_get_dir_fname2_suffix  ,
(const or_options_t *options, directory_root_t roottype, const char *sub1, const char *sub2, const char *suffix)   
)

Return a newly allocated string holding a filename relative to the directory in options specified by roottype. If sub1 is present, it is the first path component after the data directory. If sub2 is also present, it is the second path component after the data directory. If suffix is present, it is appended to the filename.

Note: Consider using macros in config.h that wrap this function; you should probably never need to call it as-is.

Definition at line 8066 of file config.c.

References tor_assert().

◆ normalize_nickname_list()

static int normalize_nickname_list ( config_line_t **  normalized_out,
const config_line_t lst,
const char *  name,
char **  msg 
)
static

Verify whether lst is a list of strings containing valid-looking comma-separated nicknames, or NULL. Will normalise lst to prefix '$' to any nickname or fingerprint that needs it. Also splits comma-separated list elements into multiple elements. Return 0 on success. Warn and return -1 on failure.

Definition at line 4963 of file config.c.

◆ open_and_add_file_log()

STATIC int open_and_add_file_log ( const log_severity_list_t severity,
const char *  filename,
int  truncate_log 
)

As add_file_log, but open the file as appropriate.

Definition at line 5684 of file config.c.

References add_file_log(), and tor_open_cloexec().

◆ opt_streq()

static int opt_streq ( const char *  s1,
const char *  s2 
)
static

Helper: return true iff s1 and s2 are both NULL, or both non-NULL equal strings.

Definition at line 4721 of file config.c.

References strcmp_opt().

Referenced by config_maybe_load_geoip_files_().

◆ option_get_assignment()

config_line_t* option_get_assignment ( const or_options_t options,
const char *  key 
)

Return a canonical list of the options assigned for key.

Definition at line 2606 of file config.c.

References config_get_assigned_option(), and options_format.

Referenced by handle_control_getconf().

◆ option_get_canonical_name()

const char* option_get_canonical_name ( const char *  key)

Return the canonical name of a configuration option, or NULL if no such option exists.

Definition at line 2597 of file config.c.

References config_find_option(), struct_member_t::name, and options_format.

◆ option_is_recognized()

int option_is_recognized ( const char *  key)

Return true iff key is a valid configuration option.

Definition at line 2588 of file config.c.

References config_find_option(), and options_format.

Referenced by handle_control_getconf().

◆ options_act()

STATIC int options_act ( const or_options_t old_options)

Fetch the active option list, and take actions based on it. All of the things we do should survive being done repeatedly. If present, old_options contains the previous value of the options.

Return 0 if all goes well, return -1 if it's time to die.

Note: We haven't moved all the "act on new configuration" logic here yet. Some is still in do_hup() and other places.

Definition at line 1862 of file config.c.

References or_options_t::command, or_options_t::DisableDebuggerAttachment, or_options_t::NoExec, options_transition_affects_guards(), options_transition_affects_workers(), or_options_t::Sandbox, tor_disable_debugger_attach(), and tor_disable_spawning_background_processes().

Referenced by set_options().

◆ options_act_reversible()

static int options_act_reversible ( const or_options_t old_options,
char **  msg 
)
static

Fetch the active option list, and take actions based on it. All of the things we do should survive being done repeatedly. If present, old_options contains the previous value of the options.

Return 0 if all goes well, return -1 if things went badly.

Definition at line 1433 of file config.c.

References or_options_t::command, or_options_t::ControlSocket, or_options_t::ControlSocketsGroupWritable, get_min_log_level(), or_options_t::RunAsDaemon, start_daemon(), and start_daemon_has_been_called().

Referenced by set_options().

◆ options_any_client_port_set()

int options_any_client_port_set ( const or_options_t options)

Return true if any option is set in options to make us behave as a client.

Definition at line 8503 of file config.c.

Referenced by handle_missing_protocol_warning().

◆ options_dump()

char* options_dump ( const or_options_t options,
int  how_to_dump 
)

Return a string containing a possible configuration file that would give the configuration in options. If minimal is true, do not include options that are the same as Tor's defaults.

Definition at line 3024 of file config.c.

◆ options_free_cb()

static void options_free_cb ( void *  options)
static

Callback to free an or_options_t

Definition at line 3180 of file config.c.

References or_options_free_().

◆ options_init()

void options_init ( or_options_t options)

Set options to hold reasonable defaults for most options. Each option defaults to zero.

Definition at line 3014 of file config.c.

References config_init(), and options_format.

◆ options_init_from_string()

setopt_err_t options_init_from_string ( const char *  cf_defaults,
const char *  cf,
int  command,
const char *  command_arg,
char **  msg 
)

Load the options from the configuration in cf, validate them for consistency and take actions based on them.

Return 0 if success, negative on error:

  • -1 for general errors.
  • -2 for failure to parse/validate,
  • -3 for transition not allowed
  • -4 for error while setting the new options

Definition at line 5402 of file config.c.

Referenced by handle_control_loadconf().

◆ options_init_from_torrc()

int options_init_from_torrc ( int  argc,
char **  argv 
)

Read a configuration file into options, finding the configuration file location based on the command line. After loading the file call options_init_from_string() to load the config. Return 0 if success, -1 if failure, and 1 if we succeeded but should exit anyway.

Definition at line 5183 of file config.c.

References config_line_find(), config_parse_commandline(), global_cmdline_only_options, global_cmdline_options, have_parsed_cmdline, list_deprecated_options(), list_enabled_modules(), list_torrc_options(), print_usage(), tor_libevent_get_header_version_str(), and tor_libevent_get_version_str().

◆ options_init_logs()

static int options_init_logs ( const or_options_t old_options,
or_options_t options,
int  validate_only 
)
static

Initialize the logs based on the configuration file.

Definition at line 5701 of file config.c.

References or_options_t::LogTimeGranularity, and or_options_t::RunAsDaemon.

◆ options_need_geoip_info()

int options_need_geoip_info ( const or_options_t options,
const char **  reason_out 
)

If we need to have a GEOIP ip-to-country map to run with our configured options, return 1 and set *reason_out to a description of why.

Definition at line 1734 of file config.c.

References or_options_t::EntryNodes, or_options_t::ExcludeExitNodes, or_options_t::ExcludeNodes, or_options_t::ExitNodes, or_options_t::HSLayer2Nodes, or_options_t::HSLayer3Nodes, or_options_t::MiddleNodes, routerset_needs_geoip(), and should_record_bridge_info().

◆ options_new()

or_options_t* options_new ( void  )

Return a new empty or_options_t. Used for testing.

Definition at line 3006 of file config.c.

References config_new(), and options_format.

◆ options_save_current()

int options_save_current ( void  )

Save the current configuration file value to disk. Return 0 on success, -1 on failure.

Definition at line 8008 of file config.c.

References get_torrc_fname(), and write_configuration_file().

Referenced by handle_control_saveconf().

◆ options_transition_affects_descriptor()

static int options_transition_affects_descriptor ( const or_options_t old_options,
const or_options_t new_options 
)
static

Return 1 if any change from old_options to new_options will require us to generate a new descriptor; else return 0.

Definition at line 4834 of file config.c.

◆ options_transition_affects_dirauth_timing()

static int options_transition_affects_dirauth_timing ( const or_options_t old_options,
const or_options_t new_options 
)
static

Return true if changing the configuration from old to new affects the timing of the voting subsystem

Definition at line 1831 of file config.c.

References tor_assert().

◆ options_transition_affects_guards()

static int options_transition_affects_guards ( const or_options_t old_options,
const or_options_t new_options 
)
static

Return true if changing the configuration from old to new affects the guard subsystem.

Definition at line 1803 of file config.c.

References tor_assert().

Referenced by options_act().

◆ options_transition_affects_workers()

static int options_transition_affects_workers ( const or_options_t old_options,
const or_options_t new_options 
)
static

Return 1 if any change from old_options to new_options will require us to rotate the CPU and DNS workers; else return 0.

Definition at line 4810 of file config.c.

Referenced by options_act().

◆ options_transition_allowed()

static int options_transition_allowed ( const or_options_t old,
const or_options_t new_val,
char **  msg 
)
static

Check if any of the previous options have changed but aren't allowed to.

Definition at line 4728 of file config.c.

◆ options_trial_assign()

setopt_err_t options_trial_assign ( config_line_t list,
unsigned  flags,
char **  msg 
)

Try assigning list to the global options. You do this by duping options, assigning list to the new one, then validating it. If it's ok, then throw out the old one and stick with the new one. Else, revert to old and return failure. Return SETOPT_OK on success, or a setopt_err_t on failure.

If not success, point *msg to a newly allocated string describing what went wrong.

Definition at line 2621 of file config.c.

References config_assign(), config_dup(), global_default_options, in_option_validation, options_format, and options_validate().

◆ options_validate()

STATIC int options_validate ( or_options_t old_options,
or_options_t options,
or_options_t default_options,
int  from_setconf,
char **  msg 
)

Return 0 if every setting in options is reasonable, is a permissible transition from old_options, and none of the testing-only settings differ from default_options unless in testing mode. Else return -1. Should have no side effects, except for normalizing the contents of options.

On error, tor_strdup an error explanation into *msg.

XXX If from_setconf, we were called by the controller, and our Log line should stay empty. If it's 0, then give us a default log if there are no logs defined.

If get_bindaddr_from_transport_listen_line() fails with 'transport' being NULL, it means that something went wrong while parsing the ServerTransportListenAddr line.

If get_options_from_transport_options_line() fails with 'transport' being NULL, it means that something went wrong while parsing the ServerTransportOptions line.

Definition at line 3378 of file config.c.

References parse_ports(), strcmpstart(), tor_assert(), or_options_t::UseEntryGuards, and or_options_t::UseEntryGuards_option.

Referenced by options_trial_assign().

◆ or_options_free_()

STATIC void or_options_free_ ( or_options_t options)

Release additional memory allocated in options

Definition at line 1022 of file config.c.

References or_options_t::ExcludeExitNodesUnion_, or_options_t::NodeFamilySets, and SMARTLIST_FOREACH.

Referenced by options_free_cb().

◆ parse_bridge_line()

bridge_line_t* parse_bridge_line ( const char *  line)

Parse the contents of a string, line, containing a Bridge line, into a bridge_line_t.

Validates that the IP:PORT, fingerprint, and SOCKS arguments (given to the Pluggable Transport, if a one was specified) are well-formed.

Returns NULL If the Bridge line could not be validated, and returns a bridge_line_t containing the parsed information otherwise.

Bridge line format: Bridge [transport] IP:PORT [id-fingerprint] [k=v] [k=v] ...

Definition at line 5913 of file config.c.

◆ parse_dir_authority_line()

STATIC int parse_dir_authority_line ( const char *  line,
dirinfo_type_t  required_type,
int  validate_only 
)

Read the contents of a DirAuthority line from line. If validate_only is 0, and the line is well-formed, and it shares any bits with required_type or required_type is NO_DIRINFO (zero), then add the dirserver described in the line (minus whatever bits it's missing) as a valid authority. Return 0 on success or filtering out by type, or -1 if the line isn't well-formed or if we can't add it.

Definition at line 6383 of file config.c.

References DIGEST_LEN.

◆ parse_dir_fallback_line()

int parse_dir_fallback_line ( const char *  line,
int  validate_only 
)

Read the contents of a FallbackDir line from line. If validate_only is 0, and the line is well-formed, then add the dirserver described in the line as a fallback directory. Return 0 on success, or -1 if the line isn't well-formed or if we can't add it.

Definition at line 6541 of file config.c.

References DIGEST_LEN, and smartlist_split_string().

Referenced by MOCK_IMPL().

◆ parse_outbound_addresses()

static int parse_outbound_addresses ( or_options_t options,
int  validate_only,
char **  msg 
)
static

Parse outbound bind address option lines. If validate_only is not 0 update OutboundBindAddresses in options. Only one address can be set for any of these values. On failure, set msg (if provided) to a newly allocated string containing a description of the problem and return -1.

Definition at line 8341 of file config.c.

References or_options_t::OutboundBindAddresses.

◆ parse_port_config()

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 
)

Parse port configuration for a single port type.

Read entries of the "FooPort" type from the list ports. Syntax is that FooPort can have any number of entries of the format "[Address:][Port] IsolationOptions".

In log messages, describe the port type as portname.

If no address is specified, default to defaultaddr. If no FooPort is given, default to defaultport (if 0, there is no default).

If CL_PORT_NO_STREAM_OPTIONS is set in flags, do not allow stream isolation options in the FooPort entries.

If CL_PORT_WARN_NONLOCAL is set in flags, warn if any of the ports are not on a local address. If CL_PORT_FORBID_NONLOCAL is set, this is a control port with no password set: don't even allow it.

If CL_PORT_SERVER_OPTIONS is set in flags, do not allow stream isolation options in the FooPort entries; instead allow the server-port option set.

If CL_PORT_TAKES_HOSTNAMES is set in flags, allow the options {No,}IPv{4,6}Traffic.

On success, if out is given, add a new port_cfg_t entry to out for every port that the client should listen on. Return 0 on success, -1 on failure.

Definition at line 6907 of file config.c.

References port_cfg_t::addr, CONN_TYPE_CONTROL_LISTENER, CONN_TYPE_EXT_OR_LISTENER, port_cfg_t::is_unix_addr, ISO_DEFAULT, entry_port_cfg_t::isolation_flags, port_cfg_t::port, port_cfg_line_extract_addrport(), port_cfg_new(), entry_port_cfg_t::session_group, SESSION_GROUP_UNSET, smartlist_add(), tor_addr_make_unspec(), tor_addr_parse(), port_cfg_t::type, and port_cfg_t::unix_addr.

Referenced by parse_ports().

◆ parse_ports()

static int parse_ports ( or_options_t options,
int  validate_only,
char **  msg,
int *  n_ports_out,
int *  world_writable_control_socket 
)
static

Parse all ports from options. On success, set *n_ports_out to the number of ports that are listed, update the *Port_set values in options, and return 0. On failure, set *msg to a description of the problem and return -1.

If validate_only is false, set configured_client_ports to the new list of ports parsed from options.

Definition at line 7390 of file config.c.

References CONN_TYPE_AP_LISTENER, parse_port_config(), or_options_t::SocksPort_lines, and or_options_t::UnixSocksGroupWritable.

Referenced by options_validate().

◆ parse_transport_line()

STATIC int parse_transport_line ( const or_options_t options,
const char *  line,
int  validate_only,
int  server 
)

Read the contents of a ClientTransportPlugin or ServerTransportPlugin line from line, depending on the value of server. Return 0 if the line is well-formed, and -1 if it isn't.

If validate_only is 0, the line is well-formed, and the transport is needed by some bridge:

  • If it's an external proxy line, add the transport described in the line to our internal transport list.
  • If it's a managed proxy line, launch the managed proxy.

Definition at line 6031 of file config.c.

References transport_list.

◆ port_cfg_free_()

STATIC void port_cfg_free_ ( port_cfg_t port)

Free all storage held in port

Definition at line 6661 of file config.c.

References tor_free.

◆ port_cfg_line_extract_addrport()

int port_cfg_line_extract_addrport ( const char *  line,
char **  addrport_out,
int *  is_unix_out,
const char **  rest_out 
)

Take a string (line) that begins with either an address:port, a port, or an AF_UNIX address, optionally quoted, prefixed with "unix:". Parse that line, and on success, set addrport_out to a new string containing the beginning portion (without prefix). Iff there was a unix: prefix, set is_unix_out to true. On success, also set rest_out to point to the part of the line after the address portion.

Return 0 on success, -1 on failure.

Definition at line 6768 of file config.c.

References eat_whitespace(), strcmpstart(), and tor_assert().

Referenced by parse_port_config().

◆ port_cfg_new()

STATIC port_cfg_t* port_cfg_new ( size_t  namelen)

Allocate and return a new port_cfg_t with reasonable defaults.

Definition at line 6647 of file config.c.

References SIZE_T_CEILING, and tor_assert().

Referenced by parse_port_config().

◆ port_exists_by_type_addr_port()

int port_exists_by_type_addr_port ( int  listener_type,
const tor_addr_t addr,
int  port,
int  check_wildcard 
)

Return 1 if a port exists of type listener_type on addr and port. If check_wildcard is true, INADDR[6]_ANY and AF_UNSPEC addresses match any address of the appropriate family; and port -1 matches any port. To match auto ports, pass CFG_PORT_AUTO. (Does not match on the actual automatically chosen listener ports.)

Definition at line 7789 of file config.c.

References configured_ports, SMARTLIST_FOREACH_BEGIN, and tor_addr_eq.

◆ print_usage()

static void print_usage ( void  )
static

Print a usage message for tor.

Definition at line 2666 of file config.c.

Referenced by options_init_from_torrc().

◆ reset_last_resolved_addr()

void reset_last_resolved_addr ( void  )

Reset last_resolved_addr from outside this file.

Definition at line 2720 of file config.c.

References last_resolved_addr.

◆ resolve_my_address()

int resolve_my_address ( int  warn_severity,
const or_options_t options,
uint32_t *  addr_out,
const char **  method_out,
char **  hostname_out 
)

Attempt getting our non-local (as judged by tor_addr_is_internal() function) IP address using following techniques, listed in order from best (most desirable, try first) to worst (least desirable, try if everything else fails).

First, attempt using options->Address to get our non-local IP address.

If options->Address represents a non-local IP address, consider it ours.

If options->Address is a DNS name that resolves to a non-local IP address, consider this IP address ours.

If options->Address is NULL, fall back to getting local hostname and using it in above-described ways to try and get our IP address.

In case local hostname cannot be resolved to a non-local IP address, try getting an IP address of network interface in hopes it will be non-local one.

Fail if one or more of the following is true:

  • DNS name in options->Address cannot be resolved.
  • options->Address is a local host address.
  • Attempt at getting local hostname fails.
  • Attempt at getting network interface address fails.

Return 0 if all is well, or -1 if we can't find a suitable public IP address.

If we are returning 0:

  • Put our public IP address (in host order) into *addr_out.
  • If method_out is non-NULL, set *method_out to a static string describing how we arrived at our answer.
    • "CONFIGURED" - parsed from IP address string in options->Address
    • "RESOLVED" - resolved from DNS name in options->Address
    • "GETHOSTNAME" - resolved from a local hostname.
    • "INTERFACE" - retrieved from a network interface.
  • If hostname_out is non-NULL, and we resolved a hostname to get our address, set *hostname_out to a newly allocated string holding that hostname. (If we didn't get our address by resolving a hostname, set *hostname_out to NULL.)

XXXX ipv6

Definition at line 2782 of file config.c.

References or_options_t::Address, LOG_NOTICE, and tor_assert().

Referenced by MOCK_IMPL().

◆ safe_str_client_opts()

const char* safe_str_client_opts ( const or_options_t options,
const char *  address 
)

Make address – a piece of information related to our operation as a client – safe to log according to the settings in options->SafeLogging, and return it.

(We return "[scrubbed]" if SafeLogging is "1", and address otherwise.)

Definition at line 1091 of file config.c.

References tor_assert().

◆ safe_str_opts()

const char* safe_str_opts ( const or_options_t options,
const char *  address 
)

Make address – a piece of information of unspecified sensitivity – safe to log according to the settings in options->SafeLogging, and return it.

(We return "[scrubbed]" if SafeLogging is anything besides "0", and address otherwise.)

Definition at line 1112 of file config.c.

References tor_assert().

◆ set_options()

int set_options ( or_options_t new_val,
char **  msg 
)

Change the current global options to contain new_val instead of their current value; take action based on the new value; free the old value as necessary. Returns 0 on success, -1 on failure.

Definition at line 951 of file config.c.

References global_options, options_act(), options_act_reversible(), tor_assert(), and tor_event_loop_shutdown_is_pending().

◆ set_protocol_warning_severity_level()

static void set_protocol_warning_severity_level ( int  warning_severity)
static

Set the protocol warning severity level to severity.

Definition at line 1169 of file config.c.

References atomic_counter_exchange(), and protocol_warning_severity_level.

Referenced by init_protocol_warning_severity_level().

◆ validate_data_directories()

static int validate_data_directories ( or_options_t options)
static

Check and normalize the values of options->{Key,Data,Cache}Directory; return 0 if it is sane, -1 otherwise.

Definition at line 7883 of file config.c.

References or_options_t::DataDirectory, or_options_t::DataDirectory_option, get_data_directory(), and tor_free.

◆ validate_dir_servers()

static int validate_dir_servers ( or_options_t options,
or_options_t old_options 
)
static

Look at all the config options for using alternate directory authorities, and make sure none of them are broken. Also, warn the user if we changed any dangerous ones.

Definition at line 1245 of file config.c.

References or_options_t::AlternateBridgeAuthority, or_options_t::AlternateDirAuthority, and or_options_t::DirAuthorities.

◆ validate_ports_csv()

static int validate_ports_csv ( smartlist_t sl,
const char *  name,
char **  msg 
)
static

Return 0 if every element of sl is a string holding a decimal representation of a port number, or if sl is NULL. Otherwise set *msg and return -1.

Definition at line 3053 of file config.c.

◆ validate_transport_socks_arguments()

static int validate_transport_socks_arguments ( const smartlist_t args)
static

Given a smartlist of SOCKS arguments to be passed to a transport proxy in args, validate them and return -1 if they are corrupted. Return 0 if they seem OK.

Definition at line 5853 of file config.c.

References tor_assert().

◆ warn_about_relative_paths()

static int warn_about_relative_paths ( or_options_t options)
static

◆ warn_if_option_path_is_relative()

static int warn_if_option_path_is_relative ( const char *  option,
char *  filepath 
)
static

Log a warning message iff filepath is not absolute. Warning message must contain option name option and an absolute path that filepath will resolve to.

In case filepath is absolute, do nothing.

Return 1 if there were relative paths; 0 otherwise.

Definition at line 3204 of file config.c.

References make_path_absolute(), and path_is_relative().

Referenced by warn_about_relative_paths().

◆ warn_nonlocal_client_ports()

static void warn_nonlocal_client_ports ( const smartlist_t ports,
const char *  portname,
const int  listener_type 
)
static

Warn for every port in ports of type listener_type that is on a publicly routable address.

Definition at line 6669 of file config.c.

References SMARTLIST_FOREACH_BEGIN.

◆ warn_nonlocal_controller_ports()

static void warn_nonlocal_controller_ports ( smartlist_t ports,
unsigned  forbid_nonlocal 
)
static

Given a list of port_cfg_t in ports, warn if any controller port there is listening on any non-loopback address. If forbid_nonlocal is true, then emit a stronger warning and remove the port from the list.

Definition at line 6720 of file config.c.

References CONN_TYPE_CONTROL_LISTENER, SMARTLIST_FOREACH_BEGIN, and tor_addr_is_loopback().

◆ warn_nonlocal_ext_orports()

static void warn_nonlocal_ext_orports ( const smartlist_t ports,
const char *  portname 
)
static

Warn for every Extended ORPort port in ports that is on a publicly routable address.

Definition at line 6697 of file config.c.

References CONN_TYPE_EXT_OR_LISTENER, and SMARTLIST_FOREACH_BEGIN.

◆ write_configuration_file()

static int write_configuration_file ( const char *  fname,
const or_options_t options 
)
static

Save a configuration file for the configuration in options into the file fname. If the file already exists, and doesn't begin with GENERATED_FILE_PREFIX, rename it. Otherwise replace it. Return 0 on success, -1 on failure.

Definition at line 7933 of file config.c.

References file_status().

Referenced by options_save_current().

◆ write_to_data_subdir()

int write_to_data_subdir ( const char *  subdir,
const char *  fname,
const char *  str,
const char *  descr 
)

Create a file named fname with contents str in the subdirectory subdir of the data directory. descr should be a short description of the file's content and will be used for the warning message, if it's present and the write process fails. Return 0 on success, -1 otherwise.

Definition at line 8132 of file config.c.

Variable Documentation

◆ CMDLINE_ONLY_OPTIONS

const { ... } CMDLINE_ONLY_OPTIONS[]
Initial value:
= {
{ "-f", ARGUMENT_NECESSARY },
{ "--allow-missing-torrc", TAKES_NO_ARGUMENT },
{ "--defaults-torrc", ARGUMENT_NECESSARY },
{ "--hash-password", ARGUMENT_NECESSARY },
{ "--dump-config", ARGUMENT_OPTIONAL },
{ "--list-fingerprint", TAKES_NO_ARGUMENT },
{ "--keygen", TAKES_NO_ARGUMENT },
{ "--key-expiration", ARGUMENT_OPTIONAL },
{ "--newpass", TAKES_NO_ARGUMENT },
{ "--no-passphrase", TAKES_NO_ARGUMENT },
{ "--passphrase-fd", ARGUMENT_NECESSARY },
{ "--verify-config", TAKES_NO_ARGUMENT },
{ "--ignore-missing-torrc", TAKES_NO_ARGUMENT },
{ "--quiet", TAKES_NO_ARGUMENT },
{ "--hush", TAKES_NO_ARGUMENT },
{ "--version", TAKES_NO_ARGUMENT },
{ "--list-modules", TAKES_NO_ARGUMENT },
{ "--library-versions", TAKES_NO_ARGUMENT },
{ "-h", TAKES_NO_ARGUMENT },
{ "--help", TAKES_NO_ARGUMENT },
{ "--list-torrc-options", TAKES_NO_ARGUMENT },
{ "--list-deprecated-options",TAKES_NO_ARGUMENT },
{ "--nt-service", TAKES_NO_ARGUMENT },
{ "-nt-service", TAKES_NO_ARGUMENT },
{ NULL, 0 },
}

◆ configured_ports

smartlist_t* configured_ports = NULL
static

List of port_cfg_t for all configured ports.

Definition at line 916 of file config.c.

Referenced by get_first_advertised_addr_by_type_af(), get_first_listener_addrport_string(), MOCK_IMPL(), and port_exists_by_type_addr_port().

◆ default_authorities

const char* default_authorities[]
static

List of default directory authorities

Definition at line 1197 of file config.c.

◆ default_fallbacks

const char* default_fallbacks[]
static

List of fallback directory authorities. The list is generated by opt-in of relays that meet certain stability criteria.

Definition at line 1205 of file config.c.

Referenced by MOCK_IMPL().

◆ global_cmdline_only_options

config_line_t* global_cmdline_only_options = NULL
static

Non-configuration options set by the command line

Definition at line 910 of file config.c.

Referenced by options_init_from_torrc().

◆ global_cmdline_options

config_line_t* global_cmdline_options = NULL
static

Configuration options set by command line.

Definition at line 908 of file config.c.

Referenced by options_init_from_torrc().

◆ global_default_options

or_options_t* global_default_options = NULL
static

The fallback options_t object; this is where we look for options not in torrc before we fall back to Tor's defaults.

Definition at line 902 of file config.c.

Referenced by config_free_all(), and options_trial_assign().

◆ global_dirfrontpagecontents

char* global_dirfrontpagecontents = NULL
static

Contents of most recently read DirPortFrontPage file.

Definition at line 914 of file config.c.

Referenced by MOCK_IMPL().

◆ global_options

or_options_t* global_options = NULL
static

Command-line and config-file options.

Definition at line 899 of file config.c.

Referenced by config_free_all(), MOCK_IMPL(), and set_options().

◆ have_parsed_cmdline

int have_parsed_cmdline = 0
static

Boolean: Have we parsed the command line?

Definition at line 912 of file config.c.

Referenced by options_init_from_torrc().

◆ in_option_validation

int in_option_validation = 0
static

True iff we're currently validating options, and any calls to get_options() are likely to be bugs.

Definition at line 919 of file config.c.

Referenced by options_trial_assign().

◆ last_resolved_addr

uint32_t last_resolved_addr = 0
static

Last value actually set by resolve_my_address.

Definition at line 2709 of file config.c.

Referenced by get_last_resolved_addr(), and reset_last_resolved_addr().

◆ option_abbrevs_

config_abbrev_t option_abbrevs_[]
static

A list of abbreviations and aliases to map command-line options, obsolete option names, or alternative option names, to their current values.

Definition at line 194 of file config.c.

◆ option_deprecation_notes_

const config_deprecation_t option_deprecation_notes_[]
static
Initial value:
= {
{ "HTTPProxy", "It only applies to direct unencrypted HTTP connections "
"to your directory server, which your Tor probably wasn't using." },
{ "HTTPProxyAuthenticator", "HTTPProxy is deprecated in favor of HTTPSProxy "
"which should be used with HTTPSProxyAuthenticator." },
{ "ReachableDirAddresses", "It has no effect on relays, and has had no "
"effect on clients since 0.2.8." },
{ "ClientPreferIPv6DirPort", "It has no effect on relays, and has had no "
"effect on clients since 0.2.8." },
{ NULL, NULL }
}

Definition at line 814 of file config.c.

◆ option_vars_

config_var_t option_vars_[]
static

Array of configuration options. Until we disallow nonstandard abbreviations, order is significant, since the first matching option will be chosen first.

Definition at line 315 of file config.c.

Referenced by getinfo_helper_config(), and list_torrc_options().

◆ options_format

STATIC config_format_t options_format
Initial value:
= {
sizeof(or_options_t),
{
"or_options_t",
offsetof(or_options_t, magic_),
},
option_deprecation_notes_,
options_validate_cb,
NULL
}
static config_abbrev_t option_abbrevs_[]
Definition: config.c:194
static config_var_t option_vars_[]
Definition: config.c:315
static void options_free_cb(void *options)
Definition: config.c:3180
#define OR_OPTIONS_MAGIC
Definition: config.c:876

Configuration format for or_options_t.

Definition at line 879 of file config.c.

Referenced by option_get_assignment(), option_get_canonical_name(), option_is_recognized(), options_init(), options_new(), and options_trial_assign().

◆ protocol_warning_severity_level

atomic_counter_t protocol_warning_severity_level
static

The severity level that should be used for warnings of severity LOG_PROTOCOL_WARN.

We keep this outside the options, and we use an atomic_counter_t, in case one thread needs to use LOG_PROTOCOL_WARN while an option transition is happening in the main thread.

Definition at line 1157 of file config.c.

Referenced by cleanup_protocol_warning_severity_level(), get_protocol_warning_severity_level(), init_protocol_warning_severity_level(), and set_protocol_warning_severity_level().

◆ testing_tor_network_defaults

const config_var_t testing_tor_network_defaults[]
static

Override default values with these if the user sets the TestingTorNetwork option.

Definition at line 771 of file config.c.

◆ torrc_defaults_fname

char* torrc_defaults_fname = NULL
static

Name of the most recently read torrc-defaults file.

Definition at line 906 of file config.c.

Referenced by get_torrc_fname(), and load_torrc_from_disk().

◆ torrc_fname

char* torrc_fname = NULL
static

Name of most recently read torrc file.

Definition at line 904 of file config.c.

Referenced by get_torrc_fname(), and load_torrc_from_disk().