Tor 0.4.9.1-alpha-dev
|
Code to interpret the user's configuration of Tor. More...
#include "core/or/or.h"
#include "app/config/config.h"
#include "lib/confmgt/confmgt.h"
#include "app/config/statefile.h"
#include "app/main/main.h"
#include "app/main/subsysmgr.h"
#include "core/mainloop/connection.h"
#include "core/mainloop/mainloop.h"
#include "core/mainloop/netstatus.h"
#include "core/or/channel.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 "trunnel/conflux.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/dircache/dirserv.h"
#include "feature/dirclient/dirclient_modes.h"
#include "feature/hibernate/hibernate.h"
#include "feature/hs/hs_config.h"
#include "feature/hs/hs_pow.h"
#include "feature/metrics/metrics.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/relay/relay_config.h"
#include "feature/relay/transport_config.h"
#include "lib/geoip/geoip.h"
#include "feature/stats/geoip_stats.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/osinfo/libc.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/authmode.h"
#include "feature/dirauth/dirauth_config.h"
#include "core/or/connection_st.h"
#include "core/or/port_cfg_st.h"
#include "auth_dirs.inc"
#include "fallback_dirs.inc"
#include "testnet.inc"
Go to the source code of this file.
Data Structures | |
struct | listener_transaction_t |
struct | log_transaction_t |
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) CONFIG_VAR_ETYPE(or_options_t, varname, conftype, member, 0, initvalue) |
#define | VAR_D(varname, conftype, member, initvalue) CONFIG_VAR_DEFN(or_options_t, varname, conftype, member, 0, initvalue) |
#define | VAR_NODUMP(varname, conftype, member, initvalue) |
#define | VAR_NODUMP_IMMUTABLE(varname, conftype, member, initvalue) |
#define | VAR_INVIS(varname, conftype, member, initvalue) |
#define | V(member, conftype, initvalue) VAR(#member, conftype, member, initvalue) |
#define | VAR_IMMUTABLE(varname, conftype, member, initvalue) |
#define | V_IMMUTABLE(member, conftype, initvalue) VAR_IMMUTABLE(#member, conftype, member, initvalue) |
#define | V_D(member, type, initvalue) VAR_D(#member, type, member, initvalue) |
#define | OBSOLETE(varname) CONFIG_VAR_OBSOLETE(varname) |
#define | VPORT(member) |
#define | UINT64_MAX_STRING "18446744073709551615" |
#define | OR_OPTIONS_MAGIC 9090909 |
#define | CHECK_OPTIONS_MAGIC(opt) |
#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 | MAX_CIRCS_AVAILABLE_TIME (24*60*60) |
#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 | MIN_SERVER_MB 64 |
#define | MIN_UNWARNED_SERVER_MB 256 |
#define | MIN_UNWARNED_CLIENT_MB 64 |
#define | ONE_GIGABYTE (UINT64_C(1) << 30) |
#define | ONE_MEGABYTE (UINT64_C(1) << 20) |
#define | RAM_IS_VERY_LARGE(x) (0) |
#define | BAD_CHANGE_TO(opt, how) |
#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 { ARGUMENT_NONE = 0 , ARGUMENT_NECESSARY = 1 , ARGUMENT_OPTIONAL = 2 } |
Functions | |
DUMMY_TYPECHECK_INSTANCE (or_options_t) | |
static int | options_check_transition_cb (const void *old, const void *new, char **msg) |
static int | validate_data_directories (or_options_t *options) |
static int | write_configuration_file (const char *fname, const or_options_t *options) |
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 (const void *old_options, void *options, char **msg) |
static void | cleanup_protocol_warning_severity_level (void) |
static void | set_protocol_warning_severity_level (int warning_severity) |
static void | options_clear_cb (const config_mgr_t *mgr, void *opts) |
static setopt_err_t | options_validate_and_set (const or_options_t *old_options, or_options_t *new_options, char **msg_out) |
static void | options_rollback_listener_transaction (struct listener_transaction_t *xn) |
STATIC const config_mgr_t * | get_options_mgr (void) |
or_options_t * | get_options_mutable (void) |
const or_options_t * | get_options (void) |
static config_line_t * | get_options_defaults (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) |
void | add_default_fallback_dir_servers (void) |
static int | validate_dir_servers (const or_options_t *options, const 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) |
static int | options_act_once_on_startup (char **msg_out) |
static int | options_switch_id (char **msg_out) |
static int | compute_group_readable_flag (const char *datadir, const char *subdir, int datadir_gr, int subdir_gr) |
STATIC int | options_create_directories (char **msg_out) |
static listener_transaction_t * | options_start_listener_transaction (const or_options_t *old_options, char **msg_out) |
static void | options_commit_listener_transaction (listener_transaction_t *xn) |
STATIC log_transaction_t * | options_start_log_transaction (const or_options_t *old_options, char **msg_out) |
STATIC void | options_commit_log_transaction (log_transaction_t *xn) |
STATIC void | options_rollback_log_transaction (log_transaction_t *xn) |
STATIC int | options_act_reversible (const or_options_t *old_options, char **msg) |
int | options_need_geoip_info (const or_options_t *options, const char **reason_out) |
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) |
parsed_cmdline_t * | config_parse_commandline (int argc, char **argv, int ignore_errors) |
void | parsed_cmdline_free_ (parsed_cmdline_t *cmdline) |
int | option_is_recognized (const char *key) |
const char * | option_get_canonical_name (const char *key) |
config_line_t * | option_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) |
static void | print_library_versions (void) |
static int | handle_cmdline_no_passphrase (tor_cmdline_mode_t command) |
static int | handle_cmdline_format (tor_cmdline_mode_t command, const char *value) |
static int | handle_cmdline_newpass (tor_cmdline_mode_t command) |
static int | handle_cmdline_passphrase_fd (tor_cmdline_mode_t command, const char *value) |
static int | handle_cmdline_master_key (tor_cmdline_mode_t command, const char *value) |
int | using_default_dir_authorities (const or_options_t *options) |
or_options_t * | options_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) |
int | config_ensure_bandwidth_cap (uint64_t *value, const char *desc, char **msg) |
static int | warn_if_option_path_is_relative (const char *option, const char *filepath) |
static int | warn_about_relative_paths (const 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 uint64_t | compute_real_max_mem_in_queues (const uint64_t val, bool is_server) |
static const char * | get_default_conf_file (int defaults_file) |
static char * | find_torrc_filename (const 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 (const 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 | options_init_log_granularity (const or_options_t *options, int validate_only) |
STATIC int | options_init_logs (const or_options_t *old_options, const or_options_t *options, int validate_only) |
static int | validate_transport_socks_arguments (const smartlist_t *args) |
void | bridge_line_free_ (bridge_line_t *bridge_line) |
bridge_line_t * | parse_bridge_line (const char *line) |
STATIC int | parse_tcp_proxy_line (const char *line, or_options_t *options, char **msg) |
int | pt_parse_transport_line (const or_options_t *options, const char *line, int validate_only, int server) |
static int | parse_dirauth_dirport (dir_server_t *ds, const char *flag) |
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) |
port_cfg_t * | port_cfg_new (size_t namelen) |
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_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) |
int | port_parse_config (smartlist_t *out, const config_line_t *ports, const char *portname, int listener_type, const char *defaultaddr, int defaultport, const unsigned flags) |
int | port_count_real_listeners (const smartlist_t *ports, int listenertype, int count_sockets) |
STATIC int | parse_ports (or_options_t *options, int validate_only, char **msg, int *n_ports_out, int *world_writable_control_socket) |
int | port_binds_ipv4 (const port_cfg_t *port) |
int | port_binds_ipv6 (const port_cfg_t *port) |
const smartlist_t * | get_configured_ports (void) |
char * | get_first_listener_addrport_string (int listener_type) |
static const port_cfg_t * | portconf_get_first_advertised (int listener_type, int address_family) |
int | portconf_get_first_advertised_port (int listener_type, int address_family) |
const tor_addr_t * | portconf_get_first_advertised_addr (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) |
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) |
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) |
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.
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:
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.
#define BAD_CHANGE_TO | ( | opt, | |
how | |||
) |
#define CHECK_DEFAULT | ( | arg | ) |
#define CHECK_OPTIONS_MAGIC | ( | opt | ) |
#define COMPLAIN | ( | args, | |
... | |||
) | STMT_BEGIN log_warn(LD_CONFIG, args, ##__VA_ARGS__); STMT_END |
#define GENERATED_FILE_COMMENT |
#define GENERATED_FILE_PREFIX |
#define MAX_CIRCS_AVAILABLE_TIME (24*60*60) |
#define MAX_MAX_CIRCUIT_DIRTINESS (30*24*60*60) |
#define MIN_CIRCUIT_STREAM_TIMEOUT 10 |
#define MIN_MAX_CIRCUIT_DIRTINESS 10 |
#define OBSOLETE | ( | varname | ) | CONFIG_VAR_OBSOLETE(varname) |
#define OR_OPTIONS_MAGIC 9090909 |
Magic value for or_options_t.
#define RECOMMENDED_MIN_CIRCUIT_BUILD_TIMEOUT (10) |
#define REJECT | ( | arg | ) | STMT_BEGIN *msg = tor_strdup(arg); return -1; STMT_END |
#define SB_NOCHANGE_INT | ( | opt | ) |
#define SB_NOCHANGE_LINELIST | ( | opt | ) |
#define SB_NOCHANGE_STR | ( | opt | ) |
#define UINT64_MAX_STRING "18446744073709551615" |
#define V | ( | member, | |
conftype, | |||
initvalue | |||
) | VAR(#member, conftype, member, initvalue) |
#define V_D | ( | member, | |
type, | |||
initvalue | |||
) | VAR_D(#member, type, member, initvalue) |
#define V_IMMUTABLE | ( | member, | |
conftype, | |||
initvalue | |||
) | VAR_IMMUTABLE(#member, conftype, member, initvalue) |
#define VAR | ( | varname, | |
conftype, | |||
member, | |||
initvalue | |||
) | CONFIG_VAR_ETYPE(or_options_t, varname, conftype, member, 0, initvalue) |
#define VAR_D | ( | varname, | |
conftype, | |||
member, | |||
initvalue | |||
) | CONFIG_VAR_DEFN(or_options_t, varname, conftype, member, 0, initvalue) |
#define VAR_IMMUTABLE | ( | varname, | |
conftype, | |||
member, | |||
initvalue | |||
) |
#define VAR_INVIS | ( | varname, | |
conftype, | |||
member, | |||
initvalue | |||
) |
#define VAR_NODUMP | ( | varname, | |
conftype, | |||
member, | |||
initvalue | |||
) |
#define VAR_NODUMP_IMMUTABLE | ( | varname, | |
conftype, | |||
member, | |||
initvalue | |||
) |
#define VPORT | ( | member | ) |
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.
#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_LINELIST | ( | opt | ) | if (!CFG_EQ_LINELIST(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 YES_IF_CHANGED_SMARTLIST | ( | opt | ) | if (!CFG_EQ_SMARTLIST(old_options, new_options, opt)) return 1; |
#define YES_IF_CHANGED_STRING | ( | opt | ) | if (!CFG_EQ_STRING(old_options, new_options, opt)) return 1; |
enum takes_argument_t |
void add_default_fallback_dir_servers | ( | void | ) |
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.
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.
void bridge_line_free_ | ( | bridge_line_t * | bridge_line | ) |
Deallocate a bridge_line_t structure.
|
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 1364 of file config.c.
Referenced by options_create_directories().
int check_or_create_data_subdir | ( | const char * | subdir | ) |
|
static |
|
static |
Helper. Given a data directory (datadir) and another directory (subdir) with respective group-writable permissions datadir_gr and subdir_gr, compute whether the subdir should be group-writeable.
Definition at line 1518 of file config.c.
Referenced by options_create_directories().
STATIC uint64_t compute_real_max_mem_in_queues | ( | const uint64_t | val, |
bool | is_server | ||
) |
int config_ensure_bandwidth_cap | ( | uint64_t * | value, |
const char * | desc, | ||
char ** | msg | ||
) |
If value exceeds ROUTER_MAX_DECLARED_BANDWIDTH, write a complaint into *msg using string desc, and return -1. Else return 0.
Definition at line 2987 of file config.c.
Referenced by dirauth_options_pre_normalize().
void config_free_all | ( | void | ) |
|
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 7416 of file config.c.
Referenced by config_maybe_load_geoip_files_().
|
static |
parsed_cmdline_t * config_parse_commandline | ( | int | argc, |
char ** | argv, | ||
int | ignore_errors | ||
) |
Helper: Read a list of configuration options from the command line. If successful, return a newly allocated parsed_cmdline_t; otherwise return NULL.
If ignore_errors is set, try to recover from all recoverable errors and return the best command line we can.
Definition at line 2541 of file config.c.
Referenced by options_init_from_torrc(), and tor_init().
void config_register_addressmaps | ( | const or_options_t * | options | ) |
int consider_adding_dir_servers | ( | const or_options_t * | options, |
const or_options_t * | old_options | ||
) |
int create_keys_directory | ( | const or_options_t * | options | ) |
DUMMY_TYPECHECK_INSTANCE | ( | or_options_t | ) |
dummy instance of or_options_t, used for type-checking its members with CONF_CHECK_VAR_TYPE.
const char * escaped_safe_str | ( | const char * | address | ) |
const char * escaped_safe_str_client | ( | const char * | address | ) |
|
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 4335 of file config.c.
Referenced by load_torrc_from_disk().
const smartlist_t * get_configured_ports | ( | void | ) |
Return a list of port_cfg_t for client ports parsed from the options.
Definition at line 6720 of file config.c.
Referenced by policies_parse_exit_policy_reject_private(), portconf_get_first_advertised(), and proxy_mode().
|
static |
Allocate and return a good value for the DataDirectory based on val, which may be NULL. Return NULL on failure.
Definition at line 6902 of file config.c.
Referenced by validate_data_directories().
|
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 4301 of file config.c.
Referenced by get_torrc_fname().
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.
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 7089 of file config.c.
Referenced by cpuworker_init(), and init_libevent().
const or_options_t * get_options | ( | void | ) |
Returns the currently configured options
Definition at line 944 of file config.c.
Referenced by add_authmethods(), add_wildcarded_test_address(), address_is_invalid_destination(), assert_identity_keys_ok(), authdir_policy_badexit_address(), authdir_policy_middleonly_address(), authdir_policy_permits_address(), authdir_policy_valid_address(), bwhist_bandwidth_assess(), bwhist_fill_bandwidth_history(), channelpadding_decide_to_pad_channel(), channelpadding_get_channel_idle_timeout(), channelpadding_get_circuits_available_timeout(), check_descriptor_bandwidth_changed(), choose_good_entry_server(), choose_good_exit_server(), choose_good_exit_server_general(), choose_good_middle_server(), circpad_is_padding_allowed(), circpad_machine_conditions_apply(), circuit_all_predicted_ports_handled(), circuit_build_needed_circs(), circuit_build_no_more_hops(), circuit_build_times_count_close(), circuit_build_times_count_timeout(), circuit_build_times_get_initial_timeout(), circuit_build_times_handle_completed_hop(), circuit_build_times_init(), circuit_build_times_new_consensus_params(), circuit_build_times_parse_state(), circuit_build_times_set_timeout(), circuit_expire_building(), circuit_expire_old_circs_as_needed(), circuit_expire_old_circuits_clientside(), circuit_find_to_cannibalize(), circuit_get_open_circ_or_launch(), circuit_handle_first_hop(), circuit_log_ancient_one_hop_circuits(), circuit_note_clock_jumped(), circuit_send_intermediate_onion_skin(), circuit_stream_is_being_handled(), circuit_testing_failed(), circuit_testing_opened(), client_get_random_intro(), command_process_create_cell(), command_process_relay_cell(), compare_tor_addr_to_short_policy(), compute_retry_timeout(), config_load_geoip_file_(), configure_nameservers(), congestion_control_init_params(), conn_get_proxy_type(), connection_ap_can_use_exit(), connection_ap_expire_beginning(), connection_ap_get_original_destination(), connection_ap_handshake_attach_circuit(), connection_ap_handshake_process_socks(), connection_ap_handshake_rewrite_and_attach(), connection_ap_handshake_send_begin(), connection_ap_rewrite_and_attach_if_allowed(), connection_bucket_init(), connection_check_oos(), connection_connect_sockaddr(), connection_dir_client_request_failed(), connection_exit_begin_conn(), connection_finished_connecting(), connection_https_proxy_connect(), connection_is_rate_limited(), connection_listener_new_for_port(), connection_or_check_valid_tls_handshake(), connection_or_client_learned_peer_id(), connection_or_connect(), connection_socks5_proxy_connect(), consider_hibernation(), consider_plaintext_ports(), consider_publishable_server(), consider_recording_trackhost(), control_event_circuit_cell_stats(), control_event_conn_bandwidth(), control_event_conn_bandwidth_used(), control_ports_write_to_file(), count_loading_descriptors_progress(), cpuworker_init(), create_managed_proxy_environment(), decide_if_publishable_server(), dir_routerdesc_download_failed(), dirauth_sched_get_configured_interval(), dirauth_sched_get_cur_valid_after_time(), dirauth_set_routerstatus_from_routerinfo(), dirclient_dump_total_dls(), directory_get_from_dirserver(), directory_handle_command_post(), directory_info_has_arrived(), dirserv_compute_performance_thresholds(), dirserv_generate_networkstatus_vote_obj(), dirserv_router_has_valid_address(), dirserv_should_launch_reachability_test(), dirvote_get_preferred_voting_intervals(), dns_init(), dns_launch_correctness_checks(), dns_new_consensus_params(), dns_reset(), dns_servers_relaunch_checks(), do_dump_config(), do_hash_password(), do_hup(), do_list_fingerprint(), entry_guard_could_succeed(), entry_guards_changed_for_guard_selection(), entry_guards_expand_sample(), entry_guards_update_filtered_sets(), entry_guards_update_state(), escaped_safe_str(), escaped_safe_str_client(), evdns_log_cb(), extend_info_pick_orport(), extrainfo_dump_to_string_stats_helper(), fetch_networkstatus_callback(), fill_signing_cert_expiry(), find_and_remove_client_auth_creds_file(), format_client_stats_heartbeat(), geoip_note_client_seen(), geoip_note_ns_response(), get_accounting_bytes(), get_bridge_dl_status_by_id(), get_controller_cookie_file_name(), get_ext_or_auth_cookie_file_name(), get_guard_confirmed_min_lifetime(), get_guard_lifetime(), get_max_age_to_cache(), get_n_primary_guards(), get_proxy_addrport(), get_pt_proxy_uri(), get_time_period_length(), get_voting_interval(), getinfo_helper_events(), guard_in_node_family(), guards_update_all(), handle_cmdline_passphrase_fd(), handle_control_authenticate(), handle_control_getconf(), handle_control_saveconf(), handle_get_descriptor(), handle_get_networkstatus_bridges(), handle_signals(), hibernate_begin(), hibernate_hard_limit_reached(), hibernate_soft_limit_reached(), hs_clean_last_hid_serv_requests(), hs_dos_consensus_has_changed(), hs_pick_hsdir(), hs_service_add_ephemeral(), hs_service_map_has_changed(), hs_service_requires_uptime_circ(), init_keys(), init_v3_authority_keys(), ip_address_changed(), is_test_address(), launch_descriptor_downloads(), launch_direct_bridge_descriptor_fetch(), launch_one_resolve(), launch_test_addresses(), learned_bridge_descriptor(), list_bridge_identities(), load_service_keys(), log_cert_expiration(), log_heartbeat(), mark_circuit_unusable_for_new_conns(), mark_my_descriptor_dirty(), my_exit_policy_rejects(), net_is_completely_disabled(), net_is_disabled(), netstatus_load_from_state(), networkstatus_get_latest_consensus(), networkstatus_set_current_consensus(), node_has_preferred_descriptor(), node_ipv6_dir_preferred(), node_ipv6_or_preferred(), nodelist_add_node_and_family(), nodelist_set_consensus(), nodelist_set_routerinfo(), nodes_in_same_family(), on_hibernate_state_change(), options_act_bridge_stats(), options_act_dirauth(), options_act_dirauth_mtbf(), options_act_once_on_startup(), options_act_relay(), options_act_relay_accounting(), options_act_relay_bandwidth(), options_act_relay_desc(), options_act_relay_dir(), options_act_relay_dos(), options_act_server_transport(), options_commit_log_transaction(), options_create_directories(), options_save_current(), options_start_log_transaction(), options_switch_id(), options_trial_assign(), parse_reachable_addresses(), pathbias_check_close_success_count(), pathbias_check_use_success_count(), pathbias_measure_close_rate(), pathbias_measure_use_rate(), pathbias_scale_close_rates(), pathbias_scale_use_rates(), periodic_event_dispatch(), pick_intro_point(), pt_get_bindaddr_from_config(), pt_get_extra_info_descriptor_string(), pt_get_options_for_server_transport(), pubsub_connect(), purpose_needs_anonymity(), reachable_addr_allows(), reachable_addr_allows_rs(), reachable_addr_choose_from_rs(), record_num_bytes_transferred_impl(), refresh_all_country_info(), relay_address_new_suggestion(), rend_mid_rendezvous(), rep_hist_circbuilding_dormant(), rep_hist_dump_stats(), rep_history_clean(), rescan_periodic_events_cb(), retry_all_listeners(), rewrite_node_address_for_bridge(), route_len_for_purpose(), router_add_to_routerlist(), router_build_fresh_unsigned_extrainfo(), router_build_fresh_unsigned_routerinfo(), router_compare_to_my_exit_policy(), router_counts_toward_thresholds(), router_do_reachability_checks(), router_find_exact_exit_enclave(), router_get_my_extrainfo(), router_get_my_routerinfo_with_err(), router_have_minimum_dir_info(), router_initialize_tls_context(), router_orport_found_reachable(), router_perform_bandwidth_test(), router_should_be_dirserver(), router_should_check_reachability(), router_upload_dir_desc_to_dirservers(), router_write_fingerprint(), routerparse_init(), routers_update_status_from_consensus_networkstatus(), safe_str_client_opts(), safe_str_opts(), select_scheduler(), server_identity_key_is_set(), should_apply_guardfraction(), signewnym_impl(), sr_act_post_consensus(), store_permanent_client_auth_credentials(), tor_cleanup(), update_all_descriptor_downloads(), update_consensus_networkstatus_downloads(), update_consensus_networkstatus_fetch_time(), update_consensus_networkstatus_fetch_time_impl(), update_consensus_router_descriptor_downloads(), update_expected_bandwidth(), update_extrainfo_downloads(), update_microdesc_downloads(), update_networkstatus_downloads(), update_router_descriptor_downloads(), update_router_have_minimum_dir_info(), update_send_buffer_size(), upload_descriptor_to_hsdir(), usable_consensus_flavor(), vanguards_lite_is_enabled(), and warn_if_last_router_excluded().
|
static |
Return a set of lines for any default options that we want to override from those set in our config_var_t values.
Definition at line 958 of file config.c.
Referenced by options_init().
STATIC const config_mgr_t * get_options_mgr | ( | void | ) |
Return the global configuration manager object for torrc options.
Definition at line 918 of file config.c.
Referenced by getinfo_helper_config(), list_deprecated_options(), list_torrc_options(), option_get_assignment(), option_get_canonical_name(), option_is_recognized(), options_init(), options_new(), options_trial_assign(), options_validate_and_set(), set_options(), and warn_about_relative_paths().
or_options_t * get_options_mutable | ( | void | ) |
Returns the currently configured options.
Definition at line 935 of file config.c.
Referenced by get_options(), handle_cmdline_newpass(), handle_cmdline_no_passphrase(), options_act(), options_commit_listener_transaction(), and options_rollback_listener_transaction().
int get_protocol_warning_severity_level | ( | void | ) |
const char * get_torrc_fname | ( | int | defaults_fname | ) |
Return the location for our configuration file. May return NULL.
Definition at line 4771 of file config.c.
Referenced by options_save_current().
int getinfo_helper_config | ( | control_connection_t * | conn, |
const char * | question, | ||
char ** | answer, | ||
const char ** | errmsg | ||
) |
|
static |
|
static |
|
static |
|
static |
|
static |
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.
|
static |
Initialize the libevent library.
Definition at line 7103 of file config.c.
Referenced by options_act_once_on_startup().
void init_protocol_warning_severity_level | ( | void | ) |
Initialize the log warning severity level for protocol warnings. Call only once at startup.
Definition at line 1187 of file config.c.
Referenced by tor_run_main().
|
static |
Print all deprecated but non-obsolete torrc options.
Definition at line 2735 of file config.c.
Referenced by options_init_from_torrc().
|
static |
|
static |
Print all non-obsolete torrc options.
Definition at line 2717 of file config.c.
Referenced by options_init_from_torrc().
|
static |
|
static |
STATIC int open_and_add_file_log | ( | const log_severity_list_t * | severity, |
const char * | filename, | ||
int | truncate_log | ||
) |
|
static |
Helper: return true iff s1 and s2 are both NULL, or both non-NULL equal strings.
Definition at line 4177 of file config.c.
Referenced by config_maybe_load_geoip_files_().
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 2672 of file config.c.
Referenced by handle_control_getconf().
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 2664 of file config.c.
Referenced by handle_control_getconf().
int option_is_recognized | ( | const char * | key | ) |
Return true iff key is a valid configuration option.
Definition at line 2656 of file config.c.
Referenced by handle_control_getconf().
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 the options_act* functions yet. Some is still in do_hup() and other places.
Definition at line 2061 of file config.c.
Referenced by set_options().
|
static |
Take case of initial startup tasks that must occur before any of the transactional option-related changes are allowed.
Definition at line 1426 of file config.c.
Referenced by options_act_reversible().
STATIC int options_act_reversible | ( | const or_options_t * | old_options, |
char ** | msg | ||
) |
Fetch the active option list, and take actions based on it. All of the things we do in this function should survive being done repeatedly, OR be done only once when starting Tor. If present, old_options contains the previous value of the options.
This function is only truly "reversible" after the first time it is run. The first time that it runs, it performs some irreversible tasks in the correct sequence between the reversible option changes.
Option changes should only be marked as "reversible" if they cannot be validated before switching them, but they can be switched back if some other validation fails.
Return 0 if all goes well, return -1 if things went badly.
Definition at line 1917 of file config.c.
Referenced by set_options().
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 7544 of file config.c.
Referenced by handle_missing_protocol_warning().
|
static |
|
static |
|
static |
Finish configuring the listeners that started to get configured with xn. Frees xn.
Definition at line 1705 of file config.c.
Referenced by options_act_reversible().
STATIC void options_commit_log_transaction | ( | log_transaction_t * | xn | ) |
Finish configuring the logs that started to get configured with xn. Frees xn.
Definition at line 1833 of file config.c.
Referenced by options_act_reversible().
STATIC int options_create_directories | ( | char ** | msg_out | ) |
Create our DataDirectory, CacheDirectory, and KeyDirectory, and set their permissions correctly.
Definition at line 1544 of file config.c.
Referenced by options_act_reversible().
char * options_dump | ( | const or_options_t * | options, |
int | how_to_dump | ||
) |
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.
void options_init | ( | or_options_t * | options | ) |
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:
Definition at line 4661 of file config.c.
Referenced by handle_control_loadconf().
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.
|
static |
Try to set our global log granularity from options->LogGranularity
, adjusting it as needed so that we are an even divisor of a second, or an even multiple of seconds. Return 0 on success, -1 on failure.
Definition at line 4894 of file config.c.
Referenced by options_init_logs().
STATIC int options_init_logs | ( | const or_options_t * | old_options, |
const or_options_t * | options, | ||
int | validate_only | ||
) |
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 1984 of file config.c.
Referenced by config_load_geoip_file_().
or_options_t * options_new | ( | void | ) |
Return a new empty or_options_t. Used for testing.
|
static |
Revert the listener configuration changes that that started to get configured with xn. Frees xn.
Definition at line 1746 of file config.c.
Referenced by options_act_reversible().
STATIC void options_rollback_log_transaction | ( | log_transaction_t * | xn | ) |
Revert the log configuration changes that that started to get configured with xn. Frees xn.
Definition at line 1887 of file config.c.
Referenced by options_act_reversible().
int options_save_current | ( | void | ) |
Save the current configuration file value to disk. Return 0 on success, -1 on failure.
Definition at line 7076 of file config.c.
Referenced by handle_control_saveconf().
|
static |
Start configuring our listeners based on the current value of get_options().
The value old_options holds either the previous options object, or NULL if we're starting for the first time.
On success, return a listener_transaction_t that we can either roll back or commit.
On failure return NULL and write a message into a newly allocated string in *msg_out.
Definition at line 1620 of file config.c.
Referenced by options_act_reversible().
STATIC log_transaction_t * options_start_log_transaction | ( | const or_options_t * | old_options, |
char ** | msg_out | ||
) |
Start configuring our logs based on the current value of get_options().
The value old_options holds either the previous options object, or NULL if we're starting for the first time.
On success, return a log_transaction_t that we can either roll back or commit.
On failure return NULL and write a message into a newly allocated string in *msg_out.
Definition at line 1798 of file config.c.
Referenced by options_act_reversible().
|
static |
Change our user ID if we're configured to do so.
Definition at line 1486 of file config.c.
Referenced by options_act_reversible().
|
static |
Return true if changing the configuration from old to new affects the guard subsystem.
Definition at line 2027 of file config.c.
Referenced by options_act().
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 2687 of file config.c.
Referenced by control_setconf_helper().
|
static |
Validate new_options. If it is valid, and it is a reasonable replacement for old_options, replace the previous value of the global options, and return return SETOPT_OK.
If it is not valid, then free new_options, set *msg_out to a newly allocated error message, and return an error code.
Definition at line 3036 of file config.c.
Referenced by options_trial_assign().
|
static |
Legacy validation/normalization callback for or_options_t. See legacy_validate_fn_t for more information.
|
static |
STATIC int options_validate_single_onion | ( | or_options_t * | options, |
char ** | msg | ||
) |
STATIC void or_options_free_ | ( | or_options_t * | options | ) |
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] ...
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.
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 5760 of file config.c.
Referenced by add_default_fallback_dir_servers().
|
static |
Parse a flag describing an extra dirport for a directory authority.
Right now, the supported format is exactly: {upload,download,voting}=http://[IP:PORT]/
. Other URL schemes, and other suffixes, might be supported in the future.
Only call this function if flag
starts with one of the above strings.
Return 0 on success, and -1 on failure.
If ds
is provided, then add any parsed dirport to ds
. If ds
is NULL, take no action other than parsing.
|
static |
|
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.
STATIC int parse_ports | ( | or_options_t * | options, |
int | validate_only, | ||
char ** | msg, | ||
int * | n_ports_out, | ||
int * | world_writable_control_socket | ||
) |
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.
STATIC int parse_tcp_proxy_line | ( | const char * | line, |
or_options_t * | options, | ||
char ** | msg | ||
) |
Parse the contents of a TCPProxy line from line and put it in options. Return 0 if the line is well-formed, and -1 if it isn't.
This will mutate only options->TCPProxyProtocol, options->TCPProxyAddr, and options->TCPProxyPort.
On error, tor_strdup an error explanation into *msg.
void parsed_cmdline_free_ | ( | parsed_cmdline_t * | cmdline | ) |
int port_binds_ipv4 | ( | const port_cfg_t * | port | ) |
int port_binds_ipv6 | ( | const port_cfg_t * | port | ) |
void port_cfg_free_ | ( | port_cfg_t * | port | ) |
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.
port_cfg_t * port_cfg_new | ( | size_t | namelen | ) |
Allocate and return a new port_cfg_t with reasonable defaults.
namelen is the length of the unix socket name (typically the filesystem path), not including the trailing NUL. It should be 0 for ports that are not zunix sockets.
int port_count_real_listeners | ( | const smartlist_t * | ports, |
int | listenertype, | ||
int | count_sockets | ||
) |
int port_exists_by_type_addr32h_port | ( | int | listener_type, |
uint32_t | addr_ipv4h, | ||
int | port, | ||
int | check_wildcard | ||
) |
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.)
int port_parse_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.
|
static |
Find and return the first configured advertised port_cfg_t
of type listener_type in address_family.
Definition at line 6790 of file config.c.
Referenced by portconf_get_first_advertised_addr(), and portconf_get_first_advertised_port().
const tor_addr_t * portconf_get_first_advertised_addr | ( | 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 6832 of file config.c.
Referenced by routerconf_find_ipv6_or_ap(), and routerconf_has_ipv6_orport().
int portconf_get_first_advertised_port | ( | 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 6820 of file config.c.
Referenced by routerconf_find_or_port().
|
static |
|
static |
Print a usage message for tor.
Definition at line 2704 of file config.c.
Referenced by options_init_from_torrc().
int pt_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:
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 | ||
) |
int set_options | ( | or_options_t * | new_val, |
char ** | msg | ||
) |
|
static |
Set the protocol warning severity level to severity.
Definition at line 1176 of file config.c.
Referenced by init_protocol_warning_severity_level().
int using_default_dir_authorities | ( | const or_options_t * | options | ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
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 3108 of file config.c.
Referenced by warn_about_relative_paths().
|
static |
|
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.
|
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 7000 of file config.c.
Referenced by options_save_current().
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.
const struct { ... } CMDLINE_ONLY_OPTIONS[] |
Table describing arguments that Tor accepts on the command line, other than those that are the same as in torrc.
tor_cmdline_mode_t command |
If not CMD_RUN_TOR, what should Tor do when it starts?
Definition at line 2468 of file config.c.
Referenced by cell_command_is_var_length(), cell_command_to_string(), command_allowed_before_handshake(), connection_ap_handshake_send_resolve(), connection_ext_or_process_inbuf(), connection_write_ext_or_command(), extend_cell_parse(), extended_cell_parse(), fetch_var_cell_from_buf(), handle_cmdline_format(), handle_cmdline_master_key(), handle_cmdline_newpass(), handle_cmdline_no_passphrase(), handle_control_obsolete(), metrics_connection_process_inbuf(), parse_http_command(), parse_http_url(), process_new(), pubsub_connect(), relay_command_to_string(), server_identity_key_is_set(), and write_packed_cell().
|
static |
List of port_cfg_t for all configured ports.
Definition at line 906 of file config.c.
Referenced by get_configured_ports(), get_first_listener_addrport_string(), and port_exists_by_type_addr_port().
|
static |
|
static |
List of fallback directory authorities. The list is generated by opt-in of relays that meet certain stability criteria.
Definition at line 794 of file config.c.
Referenced by add_default_fallback_dir_servers().
|
static |
Result of parsing the command line.
Definition at line 904 of file config.c.
Referenced by options_init_from_torrc().
|
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 898 of file config.c.
Referenced by config_free_all().
|
static |
Command-line and config-file options.
Definition at line 895 of file config.c.
Referenced by config_free_all(), get_options_mutable(), and set_options().
|
static |
True iff we have run options_act_once_on_startup()
Definition at line 911 of file config.c.
Referenced by options_act_once_on_startup(), and options_act_reversible().
|
static |
True iff we're currently validating options, and any calls to get_options() are likely to be bugs.
Definition at line 909 of file config.c.
Referenced by options_validate_and_set().
const char* name |
The string that the user has to provide.
Definition at line 2462 of file config.c.
Referenced by add_stream_log(), addr_is_in_cc_list(), clean_fname_for_stat(), client_dns_set_addressmap_impl(), compression_method_get_by_name(), config_is_same(), crypto_digest_algorithm_parse_name(), dnsserv_resolved(), fill_dns_error_values(), find_entry_by_name(), get_my_declared_family(), handle_control_getconf(), list_deprecated_options(), list_enabled_modules(), log_engine(), log_set_application_name(), managed_proxy_exit_callback(), managed_proxy_has_transport(), metrics_store_get_all(), namemap_fmt_name(), namemap_get_id(), namemap_get_id_unchecked(), namemap_get_or_create_id(), node_in_nickname_smartlist(), nodefamily_contains_nickname(), orconn_target_get_name(), periodic_events_find(), routerset_get_all_nodes(), tls_log_errors(), tor_addr_hostname_is_local(), tor_addr_lookup(), tor_gethostname(), tor_listdir(), tor_x509_name_new(), transport_add_from_config(), transport_get_by_name(), validate_ports_csv(), and warn_about_relative_paths().
|
static |
|
static |
|
static |
|
static |
Configuration format for or_options_t.
|
static |
|
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 1164 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().
int quiet |
If nonzero, set the quiet level to this. 1 is "hush", 2 is "quiet"
Definition at line 2470 of file config.c.
Referenced by add_default_log_for_quiet_level(), directory_info_has_arrived(), and tor_init().
takes_argument_t takes_argument |
|
static |
True iff we have noticed that this is a testing tor network, and we should use the corresponding defaults.
Definition at line 953 of file config.c.
Referenced by get_options_defaults().
const struct { ... } testing_tor_network_defaults[] |
Override default values with these if the user sets the TestingTorNetwork option.
Referenced by get_options_defaults().
|
static |
Name of the most recently read torrc-defaults file.
Definition at line 902 of file config.c.
Referenced by get_torrc_fname(), and load_torrc_from_disk().
|
static |
Name of most recently read torrc file.
Definition at line 900 of file config.c.
Referenced by get_torrc_fname(), and load_torrc_from_disk().