mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 23:53:32 +01:00
Make the get_options() return const
This lets us make a lot of other stuff const, allows the compiler to generate (slightly) better code, and will make me get slightly fewer patches from folks who stick mutable stuff into or_options_t. const: because not every input is an output!
This commit is contained in:
parent
22efe20309
commit
47c8433a0c
@ -1459,7 +1459,7 @@ log_unsafe_socks_warning(int socks_protocol, const char *address,
|
|||||||
{
|
{
|
||||||
static ratelim_t socks_ratelim = RATELIM_INIT(SOCKS_WARN_INTERVAL);
|
static ratelim_t socks_ratelim = RATELIM_INIT(SOCKS_WARN_INTERVAL);
|
||||||
|
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
char *m = NULL;
|
char *m = NULL;
|
||||||
if (! options->WarnUnsafeSocks)
|
if (! options->WarnUnsafeSocks)
|
||||||
return;
|
return;
|
||||||
|
@ -1948,7 +1948,7 @@ inform_testing_reachability(void)
|
|||||||
static INLINE int
|
static INLINE int
|
||||||
should_use_create_fast_for_circuit(origin_circuit_t *circ)
|
should_use_create_fast_for_circuit(origin_circuit_t *circ)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
tor_assert(circ->cpath);
|
tor_assert(circ->cpath);
|
||||||
tor_assert(circ->cpath->extend_info);
|
tor_assert(circ->cpath->extend_info);
|
||||||
|
|
||||||
@ -2083,7 +2083,7 @@ circuit_send_next_onion_skin(origin_circuit_t *circ)
|
|||||||
if (circ->build_state->onehop_tunnel)
|
if (circ->build_state->onehop_tunnel)
|
||||||
control_event_bootstrap(BOOTSTRAP_STATUS_REQUESTING_STATUS, 0);
|
control_event_bootstrap(BOOTSTRAP_STATUS_REQUESTING_STATUS, 0);
|
||||||
if (!can_complete_circuit && !circ->build_state->onehop_tunnel) {
|
if (!can_complete_circuit && !circ->build_state->onehop_tunnel) {
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
can_complete_circuit=1;
|
can_complete_circuit=1;
|
||||||
/* FFFF Log a count of known routers here */
|
/* FFFF Log a count of known routers here */
|
||||||
log_notice(LD_GENERAL,
|
log_notice(LD_GENERAL,
|
||||||
@ -2650,7 +2650,7 @@ choose_good_exit_server_general(int need_uptime, int need_capacity)
|
|||||||
smartlist_t *connections;
|
smartlist_t *connections;
|
||||||
int best_support = -1;
|
int best_support = -1;
|
||||||
int n_best_support=0;
|
int n_best_support=0;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
const smartlist_t *the_nodes;
|
const smartlist_t *the_nodes;
|
||||||
const node_t *node=NULL;
|
const node_t *node=NULL;
|
||||||
|
|
||||||
@ -2851,7 +2851,7 @@ static const node_t *
|
|||||||
choose_good_exit_server(uint8_t purpose,
|
choose_good_exit_server(uint8_t purpose,
|
||||||
int need_uptime, int need_capacity, int is_internal)
|
int need_uptime, int need_capacity, int is_internal)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
router_crn_flags_t flags = CRN_NEED_DESC;
|
router_crn_flags_t flags = CRN_NEED_DESC;
|
||||||
if (need_uptime)
|
if (need_uptime)
|
||||||
flags |= CRN_NEED_UPTIME;
|
flags |= CRN_NEED_UPTIME;
|
||||||
@ -2881,7 +2881,7 @@ choose_good_exit_server(uint8_t purpose,
|
|||||||
static void
|
static void
|
||||||
warn_if_last_router_excluded(origin_circuit_t *circ, const extend_info_t *exit)
|
warn_if_last_router_excluded(origin_circuit_t *circ, const extend_info_t *exit)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
routerset_t *rs = options->ExcludeNodes;
|
routerset_t *rs = options->ExcludeNodes;
|
||||||
const char *description;
|
const char *description;
|
||||||
uint8_t purpose = circ->_base.purpose;
|
uint8_t purpose = circ->_base.purpose;
|
||||||
@ -3095,7 +3095,7 @@ choose_good_middle_server(uint8_t purpose,
|
|||||||
const node_t *r, *choice;
|
const node_t *r, *choice;
|
||||||
crypt_path_t *cpath;
|
crypt_path_t *cpath;
|
||||||
smartlist_t *excluded;
|
smartlist_t *excluded;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
router_crn_flags_t flags = CRN_NEED_DESC;
|
router_crn_flags_t flags = CRN_NEED_DESC;
|
||||||
tor_assert(_CIRCUIT_PURPOSE_MIN <= purpose &&
|
tor_assert(_CIRCUIT_PURPOSE_MIN <= purpose &&
|
||||||
purpose <= _CIRCUIT_PURPOSE_MAX);
|
purpose <= _CIRCUIT_PURPOSE_MAX);
|
||||||
@ -3137,7 +3137,7 @@ choose_good_entry_server(uint8_t purpose, cpath_build_state_t *state)
|
|||||||
{
|
{
|
||||||
const node_t *choice;
|
const node_t *choice;
|
||||||
smartlist_t *excluded;
|
smartlist_t *excluded;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
router_crn_flags_t flags = CRN_NEED_GUARD|CRN_NEED_DESC;
|
router_crn_flags_t flags = CRN_NEED_GUARD|CRN_NEED_DESC;
|
||||||
const node_t *node;
|
const node_t *node;
|
||||||
|
|
||||||
@ -3388,7 +3388,8 @@ build_state_get_exit_nickname(cpath_build_state_t *state)
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
entry_guard_set_status(entry_guard_t *e, const node_t *node,
|
entry_guard_set_status(entry_guard_t *e, const node_t *node,
|
||||||
time_t now, or_options_t *options, const char **reason)
|
time_t now, const or_options_t *options,
|
||||||
|
const char **reason)
|
||||||
{
|
{
|
||||||
char buf[HEX_DIGEST_LEN+1];
|
char buf[HEX_DIGEST_LEN+1];
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
@ -3471,7 +3472,7 @@ entry_is_live(entry_guard_t *e, int need_uptime, int need_capacity,
|
|||||||
int assume_reachable, const char **msg)
|
int assume_reachable, const char **msg)
|
||||||
{
|
{
|
||||||
const node_t *node;
|
const node_t *node;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
tor_assert(msg);
|
tor_assert(msg);
|
||||||
|
|
||||||
if (e->bad_since) {
|
if (e->bad_since) {
|
||||||
@ -3597,7 +3598,7 @@ control_event_guard_deferred(void)
|
|||||||
#if 0
|
#if 0
|
||||||
int n = 0;
|
int n = 0;
|
||||||
const char *msg;
|
const char *msg;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
if (!entry_guards)
|
if (!entry_guards)
|
||||||
return;
|
return;
|
||||||
SMARTLIST_FOREACH(entry_guards, entry_guard_t *, entry,
|
SMARTLIST_FOREACH(entry_guards, entry_guard_t *, entry,
|
||||||
@ -3665,7 +3666,7 @@ add_an_entry_guard(const node_t *chosen, int reset_status)
|
|||||||
/** If the use of entry guards is configured, choose more entry guards
|
/** If the use of entry guards is configured, choose more entry guards
|
||||||
* until we have enough in the list. */
|
* until we have enough in the list. */
|
||||||
static void
|
static void
|
||||||
pick_entry_guards(or_options_t *options)
|
pick_entry_guards(const or_options_t *options)
|
||||||
{
|
{
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
|
|
||||||
@ -3798,7 +3799,7 @@ remove_dead_entry_guards(time_t now)
|
|||||||
* think that things are unlisted.
|
* think that things are unlisted.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
entry_guards_compute_status(or_options_t *options, time_t now)
|
entry_guards_compute_status(const or_options_t *options, time_t now)
|
||||||
{
|
{
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
digestmap_t *reasons;
|
digestmap_t *reasons;
|
||||||
@ -3988,7 +3989,7 @@ entry_nodes_should_be_added(void)
|
|||||||
/** Add all nodes in EntryNodes that aren't currently guard nodes to the list
|
/** Add all nodes in EntryNodes that aren't currently guard nodes to the list
|
||||||
* of guard nodes, at the front. */
|
* of guard nodes, at the front. */
|
||||||
static void
|
static void
|
||||||
entry_guards_prepend_from_config(or_options_t *options)
|
entry_guards_prepend_from_config(const or_options_t *options)
|
||||||
{
|
{
|
||||||
smartlist_t *entry_nodes, *entry_fps;
|
smartlist_t *entry_nodes, *entry_fps;
|
||||||
smartlist_t *old_entry_guards_on_list, *old_entry_guards_not_on_list;
|
smartlist_t *old_entry_guards_on_list, *old_entry_guards_not_on_list;
|
||||||
@ -4067,7 +4068,7 @@ entry_guards_prepend_from_config(or_options_t *options)
|
|||||||
* list already and we must stick to it.
|
* list already and we must stick to it.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
entry_list_is_constrained(or_options_t *options)
|
entry_list_is_constrained(const or_options_t *options)
|
||||||
{
|
{
|
||||||
if (options->EntryNodes)
|
if (options->EntryNodes)
|
||||||
return 1;
|
return 1;
|
||||||
@ -4084,7 +4085,7 @@ entry_list_is_constrained(or_options_t *options)
|
|||||||
const node_t *
|
const node_t *
|
||||||
choose_random_entry(cpath_build_state_t *state)
|
choose_random_entry(cpath_build_state_t *state)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
smartlist_t *live_entry_guards = smartlist_create();
|
smartlist_t *live_entry_guards = smartlist_create();
|
||||||
smartlist_t *exit_family = smartlist_create();
|
smartlist_t *exit_family = smartlist_create();
|
||||||
const node_t *chosen_exit =
|
const node_t *chosen_exit =
|
||||||
@ -4694,7 +4695,7 @@ static void
|
|||||||
launch_direct_bridge_descriptor_fetch(bridge_info_t *bridge)
|
launch_direct_bridge_descriptor_fetch(bridge_info_t *bridge)
|
||||||
{
|
{
|
||||||
char *address;
|
char *address;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
if (connection_get_by_type_addr_port_purpose(
|
if (connection_get_by_type_addr_port_purpose(
|
||||||
CONN_TYPE_DIR, &bridge->addr, bridge->port,
|
CONN_TYPE_DIR, &bridge->addr, bridge->port,
|
||||||
@ -4735,7 +4736,7 @@ retry_bridge_descriptor_fetch_directly(const char *digest)
|
|||||||
* descriptor, fetch a new copy of its descriptor -- either directly
|
* descriptor, fetch a new copy of its descriptor -- either directly
|
||||||
* from the bridge or via a bridge authority. */
|
* from the bridge or via a bridge authority. */
|
||||||
void
|
void
|
||||||
fetch_bridge_descriptors(or_options_t *options, time_t now)
|
fetch_bridge_descriptors(const or_options_t *options, time_t now)
|
||||||
{
|
{
|
||||||
int num_bridge_auths = get_n_authorities(BRIDGE_DIRINFO);
|
int num_bridge_auths = get_n_authorities(BRIDGE_DIRINFO);
|
||||||
int ask_bridge_directly;
|
int ask_bridge_directly;
|
||||||
@ -4929,7 +4930,7 @@ any_pending_bridge_descriptor_fetches(void)
|
|||||||
* down. Else return 0. If <b>act</b> is 1, then mark the down guards
|
* down. Else return 0. If <b>act</b> is 1, then mark the down guards
|
||||||
* up; else just observe and report. */
|
* up; else just observe and report. */
|
||||||
static int
|
static int
|
||||||
entries_retry_helper(or_options_t *options, int act)
|
entries_retry_helper(const or_options_t *options, int act)
|
||||||
{
|
{
|
||||||
const node_t *node;
|
const node_t *node;
|
||||||
int any_known = 0;
|
int any_known = 0;
|
||||||
@ -4968,7 +4969,7 @@ entries_retry_helper(or_options_t *options, int act)
|
|||||||
/** Do we know any descriptors for our bridges / entrynodes, and are
|
/** Do we know any descriptors for our bridges / entrynodes, and are
|
||||||
* all the ones we have descriptors for down? */
|
* all the ones we have descriptors for down? */
|
||||||
int
|
int
|
||||||
entries_known_but_down(or_options_t *options)
|
entries_known_but_down(const or_options_t *options)
|
||||||
{
|
{
|
||||||
tor_assert(entry_list_is_constrained(options));
|
tor_assert(entry_list_is_constrained(options));
|
||||||
return entries_retry_helper(options, 0);
|
return entries_retry_helper(options, 0);
|
||||||
@ -4976,7 +4977,7 @@ entries_known_but_down(or_options_t *options)
|
|||||||
|
|
||||||
/** Mark all down known bridges / entrynodes up. */
|
/** Mark all down known bridges / entrynodes up. */
|
||||||
void
|
void
|
||||||
entries_retry_all(or_options_t *options)
|
entries_retry_all(const or_options_t *options)
|
||||||
{
|
{
|
||||||
tor_assert(entry_list_is_constrained(options));
|
tor_assert(entry_list_is_constrained(options));
|
||||||
entries_retry_helper(options, 1);
|
entries_retry_helper(options, 1);
|
||||||
|
@ -51,11 +51,11 @@ void extend_info_free(extend_info_t *info);
|
|||||||
const node_t *build_state_get_exit_node(cpath_build_state_t *state);
|
const node_t *build_state_get_exit_node(cpath_build_state_t *state);
|
||||||
const char *build_state_get_exit_nickname(cpath_build_state_t *state);
|
const char *build_state_get_exit_nickname(cpath_build_state_t *state);
|
||||||
|
|
||||||
void entry_guards_compute_status(or_options_t *options, time_t now);
|
void entry_guards_compute_status(const or_options_t *options, time_t now);
|
||||||
int entry_guard_register_connect_status(const char *digest, int succeeded,
|
int entry_guard_register_connect_status(const char *digest, int succeeded,
|
||||||
int mark_relay_status, time_t now);
|
int mark_relay_status, time_t now);
|
||||||
void entry_nodes_should_be_added(void);
|
void entry_nodes_should_be_added(void);
|
||||||
int entry_list_is_constrained(or_options_t *options);
|
int entry_list_is_constrained(const or_options_t *options);
|
||||||
const node_t *choose_random_entry(cpath_build_state_t *state);
|
const node_t *choose_random_entry(cpath_build_state_t *state);
|
||||||
int entry_guards_parse_state(or_state_t *state, int set, char **msg);
|
int entry_guards_parse_state(or_state_t *state, int set, char **msg);
|
||||||
void entry_guards_update_state(or_state_t *state);
|
void entry_guards_update_state(or_state_t *state);
|
||||||
@ -72,12 +72,12 @@ void learned_router_identity(const tor_addr_t *addr, uint16_t port,
|
|||||||
void bridge_add_from_config(const tor_addr_t *addr, uint16_t port,
|
void bridge_add_from_config(const tor_addr_t *addr, uint16_t port,
|
||||||
const char *digest);
|
const char *digest);
|
||||||
void retry_bridge_descriptor_fetch_directly(const char *digest);
|
void retry_bridge_descriptor_fetch_directly(const char *digest);
|
||||||
void fetch_bridge_descriptors(or_options_t *options, time_t now);
|
void fetch_bridge_descriptors(const or_options_t *options, time_t now);
|
||||||
void learned_bridge_descriptor(routerinfo_t *ri, int from_cache);
|
void learned_bridge_descriptor(routerinfo_t *ri, int from_cache);
|
||||||
int any_bridge_descriptors_known(void);
|
int any_bridge_descriptors_known(void);
|
||||||
int any_pending_bridge_descriptor_fetches(void);
|
int any_pending_bridge_descriptor_fetches(void);
|
||||||
int entries_known_but_down(or_options_t *options);
|
int entries_known_but_down(const or_options_t *options);
|
||||||
void entries_retry_all(or_options_t *options);
|
void entries_retry_all(const or_options_t *options);
|
||||||
|
|
||||||
void entry_guards_free_all(void);
|
void entry_guards_free_all(void);
|
||||||
|
|
||||||
|
@ -979,7 +979,7 @@ circuit_find_to_cannibalize(uint8_t purpose, extend_info_t *info,
|
|||||||
int need_uptime = (flags & CIRCLAUNCH_NEED_UPTIME) != 0;
|
int need_uptime = (flags & CIRCLAUNCH_NEED_UPTIME) != 0;
|
||||||
int need_capacity = (flags & CIRCLAUNCH_NEED_CAPACITY) != 0;
|
int need_capacity = (flags & CIRCLAUNCH_NEED_CAPACITY) != 0;
|
||||||
int internal = (flags & CIRCLAUNCH_IS_INTERNAL) != 0;
|
int internal = (flags & CIRCLAUNCH_IS_INTERNAL) != 0;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
/* Make sure we're not trying to create a onehop circ by
|
/* Make sure we're not trying to create a onehop circ by
|
||||||
* cannibalization. */
|
* cannibalization. */
|
||||||
@ -1098,7 +1098,7 @@ void
|
|||||||
circuit_expire_all_dirty_circs(void)
|
circuit_expire_all_dirty_circs(void)
|
||||||
{
|
{
|
||||||
circuit_t *circ;
|
circuit_t *circ;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
for (circ=global_circuitlist; circ; circ = circ->next) {
|
for (circ=global_circuitlist; circ; circ = circ->next) {
|
||||||
if (CIRCUIT_IS_ORIGIN(circ) &&
|
if (CIRCUIT_IS_ORIGIN(circ) &&
|
||||||
|
@ -635,7 +635,7 @@ void
|
|||||||
circuit_build_needed_circs(time_t now)
|
circuit_build_needed_circs(time_t now)
|
||||||
{
|
{
|
||||||
static time_t time_to_new_circuit = 0;
|
static time_t time_to_new_circuit = 0;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
/* launch a new circ for any pending streams that need one */
|
/* launch a new circ for any pending streams that need one */
|
||||||
connection_ap_attach_pending();
|
connection_ap_attach_pending();
|
||||||
@ -1207,7 +1207,7 @@ circuit_get_open_circ_or_launch(edge_connection_t *conn,
|
|||||||
int check_exit_policy;
|
int check_exit_policy;
|
||||||
int need_uptime, need_internal;
|
int need_uptime, need_internal;
|
||||||
int want_onehop;
|
int want_onehop;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
tor_assert(conn);
|
tor_assert(conn);
|
||||||
tor_assert(circp);
|
tor_assert(circp);
|
||||||
@ -1470,7 +1470,7 @@ link_apconn_to_circ(edge_connection_t *apconn, origin_circuit_t *circ,
|
|||||||
/** Return true iff <b>address</b> is matched by one of the entries in
|
/** Return true iff <b>address</b> is matched by one of the entries in
|
||||||
* TrackHostExits. */
|
* TrackHostExits. */
|
||||||
int
|
int
|
||||||
hostname_in_track_host_exits(or_options_t *options, const char *address)
|
hostname_in_track_host_exits(const or_options_t *options, const char *address)
|
||||||
{
|
{
|
||||||
if (!options->TrackHostExits)
|
if (!options->TrackHostExits)
|
||||||
return 0;
|
return 0;
|
||||||
@ -1494,7 +1494,7 @@ hostname_in_track_host_exits(or_options_t *options, const char *address)
|
|||||||
static void
|
static void
|
||||||
consider_recording_trackhost(edge_connection_t *conn, origin_circuit_t *circ)
|
consider_recording_trackhost(edge_connection_t *conn, origin_circuit_t *circ)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
char *new_address = NULL;
|
char *new_address = NULL;
|
||||||
char fp[HEX_DIGEST_LEN+1];
|
char fp[HEX_DIGEST_LEN+1];
|
||||||
|
|
||||||
|
@ -50,7 +50,8 @@ int connection_ap_handshake_attach_chosen_circuit(edge_connection_t *conn,
|
|||||||
crypt_path_t *cpath);
|
crypt_path_t *cpath);
|
||||||
int connection_ap_handshake_attach_circuit(edge_connection_t *conn);
|
int connection_ap_handshake_attach_circuit(edge_connection_t *conn);
|
||||||
|
|
||||||
int hostname_in_track_host_exits(or_options_t *options, const char *address);
|
int hostname_in_track_host_exits(const or_options_t *options,
|
||||||
|
const char *address);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
182
src/or/config.c
182
src/or/config.c
@ -422,7 +422,7 @@ static config_var_t _option_vars[] = {
|
|||||||
|
|
||||||
/** Override default values with these if the user sets the TestingTorNetwork
|
/** Override default values with these if the user sets the TestingTorNetwork
|
||||||
* option. */
|
* option. */
|
||||||
static config_var_t testing_tor_network_defaults[] = {
|
static const config_var_t testing_tor_network_defaults[] = {
|
||||||
V(ServerDNSAllowBrokenConfig, BOOL, "1"),
|
V(ServerDNSAllowBrokenConfig, BOOL, "1"),
|
||||||
V(DirAllowPrivateAddresses, BOOL, "1"),
|
V(DirAllowPrivateAddresses, BOOL, "1"),
|
||||||
V(EnforceDistinctSubnets, BOOL, "0"),
|
V(EnforceDistinctSubnets, BOOL, "0"),
|
||||||
@ -546,39 +546,43 @@ static char *get_windows_conf_root(void);
|
|||||||
#endif
|
#endif
|
||||||
static void config_line_append(config_line_t **lst,
|
static void config_line_append(config_line_t **lst,
|
||||||
const char *key, const char *val);
|
const char *key, const char *val);
|
||||||
static void option_clear(config_format_t *fmt, or_options_t *options,
|
static void option_clear(const config_format_t *fmt, or_options_t *options,
|
||||||
config_var_t *var);
|
const config_var_t *var);
|
||||||
static void option_reset(config_format_t *fmt, or_options_t *options,
|
static void option_reset(const config_format_t *fmt, or_options_t *options,
|
||||||
config_var_t *var, int use_defaults);
|
const config_var_t *var, int use_defaults);
|
||||||
static void config_free(config_format_t *fmt, void *options);
|
static void config_free(const config_format_t *fmt, void *options);
|
||||||
static int config_lines_eq(config_line_t *a, config_line_t *b);
|
static int config_lines_eq(config_line_t *a, config_line_t *b);
|
||||||
static int option_is_same(config_format_t *fmt,
|
static int option_is_same(const config_format_t *fmt,
|
||||||
or_options_t *o1, or_options_t *o2,
|
const or_options_t *o1, const or_options_t *o2,
|
||||||
const char *name);
|
const char *name);
|
||||||
static or_options_t *options_dup(config_format_t *fmt, or_options_t *old);
|
static or_options_t *options_dup(const config_format_t *fmt,
|
||||||
static int options_validate(or_options_t *old_options, or_options_t *options,
|
const or_options_t *old);
|
||||||
|
static int options_validate(or_options_t *old_options,
|
||||||
|
or_options_t *options,
|
||||||
int from_setconf, char **msg);
|
int from_setconf, char **msg);
|
||||||
static int options_act_reversible(or_options_t *old_options, char **msg);
|
static int options_act_reversible(const or_options_t *old_options, char **msg);
|
||||||
static int options_act(or_options_t *old_options);
|
static int options_act(const or_options_t *old_options);
|
||||||
static int options_transition_allowed(or_options_t *old, or_options_t *new,
|
static int options_transition_allowed(const or_options_t *old,
|
||||||
|
const or_options_t *new,
|
||||||
char **msg);
|
char **msg);
|
||||||
static int options_transition_affects_workers(or_options_t *old_options,
|
static int options_transition_affects_workers(
|
||||||
or_options_t *new_options);
|
const or_options_t *old_options, const or_options_t *new_options);
|
||||||
static int options_transition_affects_descriptor(or_options_t *old_options,
|
static int options_transition_affects_descriptor(
|
||||||
or_options_t *new_options);
|
const or_options_t *old_options, const or_options_t *new_options);
|
||||||
static int check_nickname_list(const char *lst, const char *name, char **msg);
|
static int check_nickname_list(const char *lst, const char *name, char **msg);
|
||||||
static void config_register_addressmaps(or_options_t *options);
|
static void config_register_addressmaps(const or_options_t *options);
|
||||||
|
|
||||||
static int parse_bridge_line(const char *line, int validate_only);
|
static int parse_bridge_line(const char *line, int validate_only);
|
||||||
static int parse_dir_server_line(const char *line,
|
static int parse_dir_server_line(const char *line,
|
||||||
dirinfo_type_t required_type,
|
dirinfo_type_t required_type,
|
||||||
int validate_only);
|
int validate_only);
|
||||||
static int validate_data_directory(or_options_t *options);
|
static int validate_data_directory(or_options_t *options);
|
||||||
static int write_configuration_file(const char *fname, or_options_t *options);
|
static int write_configuration_file(const char *fname,
|
||||||
static config_line_t *get_assigned_option(config_format_t *fmt,
|
const or_options_t *options);
|
||||||
void *options, const char *key,
|
static config_line_t *get_assigned_option(const config_format_t *fmt,
|
||||||
int escape_val);
|
const void *options, const char *key,
|
||||||
static void config_init(config_format_t *fmt, void *options);
|
int escape_val);
|
||||||
|
static void config_init(const config_format_t *fmt, void *options);
|
||||||
static int or_state_validate(or_state_t *old_options, or_state_t *options,
|
static int or_state_validate(or_state_t *old_options, or_state_t *options,
|
||||||
int from_setconf, char **msg);
|
int from_setconf, char **msg);
|
||||||
static int or_state_load(void);
|
static int or_state_load(void);
|
||||||
@ -617,7 +621,7 @@ static config_var_t state_extra_var = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Configuration format for or_state_t. */
|
/** Configuration format for or_state_t. */
|
||||||
static config_format_t state_format = {
|
static const config_format_t state_format = {
|
||||||
sizeof(or_state_t),
|
sizeof(or_state_t),
|
||||||
OR_STATE_MAGIC,
|
OR_STATE_MAGIC,
|
||||||
STRUCT_OFFSET(or_state_t, _magic),
|
STRUCT_OFFSET(or_state_t, _magic),
|
||||||
@ -651,7 +655,7 @@ get_dirportfrontpage(void)
|
|||||||
|
|
||||||
/** Allocate an empty configuration object of a given format type. */
|
/** Allocate an empty configuration object of a given format type. */
|
||||||
static void *
|
static void *
|
||||||
config_alloc(config_format_t *fmt)
|
config_alloc(const config_format_t *fmt)
|
||||||
{
|
{
|
||||||
void *opts = tor_malloc_zero(fmt->size);
|
void *opts = tor_malloc_zero(fmt->size);
|
||||||
*(uint32_t*)STRUCT_VAR_P(opts, fmt->magic_offset) = fmt->magic;
|
*(uint32_t*)STRUCT_VAR_P(opts, fmt->magic_offset) = fmt->magic;
|
||||||
@ -661,12 +665,19 @@ config_alloc(config_format_t *fmt)
|
|||||||
|
|
||||||
/** Return the currently configured options. */
|
/** Return the currently configured options. */
|
||||||
or_options_t *
|
or_options_t *
|
||||||
get_options(void)
|
get_options_mutable(void)
|
||||||
{
|
{
|
||||||
tor_assert(global_options);
|
tor_assert(global_options);
|
||||||
return global_options;
|
return global_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns the currently configured options */
|
||||||
|
const or_options_t *
|
||||||
|
get_options(void)
|
||||||
|
{
|
||||||
|
return get_options_mutable();
|
||||||
|
}
|
||||||
|
|
||||||
/** Change the current global options to contain <b>new_val</b> instead of
|
/** Change the current global options to contain <b>new_val</b> instead of
|
||||||
* their current value; take action based on the new value; free the old value
|
* their current value; take action based on the new value; free the old value
|
||||||
* as necessary. Returns 0 on success, -1 on failure.
|
* as necessary. Returns 0 on success, -1 on failure.
|
||||||
@ -903,8 +914,8 @@ validate_dir_authorities(or_options_t *options, or_options_t *old_options)
|
|||||||
* as appropriate.
|
* as appropriate.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
consider_adding_dir_authorities(or_options_t *options,
|
consider_adding_dir_authorities(const or_options_t *options,
|
||||||
or_options_t *old_options)
|
const or_options_t *old_options)
|
||||||
{
|
{
|
||||||
config_line_t *cl;
|
config_line_t *cl;
|
||||||
int need_to_update =
|
int need_to_update =
|
||||||
@ -958,12 +969,12 @@ consider_adding_dir_authorities(or_options_t *options,
|
|||||||
* Return 0 if all goes well, return -1 if things went badly.
|
* Return 0 if all goes well, return -1 if things went badly.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
options_act_reversible(or_options_t *old_options, char **msg)
|
options_act_reversible(const or_options_t *old_options, char **msg)
|
||||||
{
|
{
|
||||||
smartlist_t *new_listeners = smartlist_create();
|
smartlist_t *new_listeners = smartlist_create();
|
||||||
smartlist_t *replaced_listeners = smartlist_create();
|
smartlist_t *replaced_listeners = smartlist_create();
|
||||||
static int libevent_initialized = 0;
|
static int libevent_initialized = 0;
|
||||||
or_options_t *options = get_options();
|
or_options_t *options = get_options_mutable();
|
||||||
int running_tor = options->command == CMD_RUN_TOR;
|
int running_tor = options->command == CMD_RUN_TOR;
|
||||||
int set_conn_limit = 0;
|
int set_conn_limit = 0;
|
||||||
int r = -1;
|
int r = -1;
|
||||||
@ -1056,7 +1067,7 @@ options_act_reversible(or_options_t *old_options, char **msg)
|
|||||||
/* No need to roll back, since you can't change the value. */
|
/* No need to roll back, since you can't change the value. */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (directory_caches_v2_dir_info(options)) {
|
if (directory_caches_v2_dir_info(options)) {
|
||||||
size_t len = strlen(options->DataDirectory)+32;
|
size_t len = strlen(options->DataDirectory)+32;
|
||||||
char *fn = tor_malloc(len);
|
char *fn = tor_malloc(len);
|
||||||
tor_snprintf(fn, len, "%s"PATH_SEPARATOR"cached-status",
|
tor_snprintf(fn, len, "%s"PATH_SEPARATOR"cached-status",
|
||||||
@ -1132,7 +1143,7 @@ options_act_reversible(or_options_t *old_options, char **msg)
|
|||||||
/** If we need to have a GEOIP ip-to-country map to run with our configured
|
/** If we need to have a GEOIP ip-to-country map to run with our configured
|
||||||
* options, return 1 and set *<b>reason_out</b> to a description of why. */
|
* options, return 1 and set *<b>reason_out</b> to a description of why. */
|
||||||
int
|
int
|
||||||
options_need_geoip_info(or_options_t *options, const char **reason_out)
|
options_need_geoip_info(const or_options_t *options, const char **reason_out)
|
||||||
{
|
{
|
||||||
int bridge_usage =
|
int bridge_usage =
|
||||||
options->BridgeRelay && options->BridgeRecordUsageByCountry;
|
options->BridgeRelay && options->BridgeRecordUsageByCountry;
|
||||||
@ -1157,7 +1168,7 @@ options_need_geoip_info(or_options_t *options, const char **reason_out)
|
|||||||
/** Return the bandwidthrate that we are going to report to the authorities
|
/** Return the bandwidthrate that we are going to report to the authorities
|
||||||
* based on the config options. */
|
* based on the config options. */
|
||||||
uint32_t
|
uint32_t
|
||||||
get_effective_bwrate(or_options_t *options)
|
get_effective_bwrate(const or_options_t *options)
|
||||||
{
|
{
|
||||||
uint64_t bw = options->BandwidthRate;
|
uint64_t bw = options->BandwidthRate;
|
||||||
if (bw > options->MaxAdvertisedBandwidth)
|
if (bw > options->MaxAdvertisedBandwidth)
|
||||||
@ -1171,7 +1182,7 @@ get_effective_bwrate(or_options_t *options)
|
|||||||
/** Return the bandwidthburst that we are going to report to the authorities
|
/** Return the bandwidthburst that we are going to report to the authorities
|
||||||
* based on the config options. */
|
* based on the config options. */
|
||||||
uint32_t
|
uint32_t
|
||||||
get_effective_bwburst(or_options_t *options)
|
get_effective_bwburst(const or_options_t *options)
|
||||||
{
|
{
|
||||||
uint64_t bw = options->BandwidthBurst;
|
uint64_t bw = options->BandwidthBurst;
|
||||||
if (options->RelayBandwidthBurst > 0 && bw > options->RelayBandwidthBurst)
|
if (options->RelayBandwidthBurst > 0 && bw > options->RelayBandwidthBurst)
|
||||||
@ -1190,10 +1201,10 @@ get_effective_bwburst(or_options_t *options)
|
|||||||
* here yet. Some is still in do_hup() and other places.
|
* here yet. Some is still in do_hup() and other places.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
options_act(or_options_t *old_options)
|
options_act(const or_options_t *old_options)
|
||||||
{
|
{
|
||||||
config_line_t *cl;
|
config_line_t *cl;
|
||||||
or_options_t *options = get_options();
|
or_options_t *options = get_options_mutable();
|
||||||
int running_tor = options->command == CMD_RUN_TOR;
|
int running_tor = options->command == CMD_RUN_TOR;
|
||||||
char *msg;
|
char *msg;
|
||||||
const int transition_affects_workers =
|
const int transition_affects_workers =
|
||||||
@ -1550,7 +1561,7 @@ options_act(or_options_t *old_options)
|
|||||||
* apply abbreviations that work for the config file and the command line.
|
* apply abbreviations that work for the config file and the command line.
|
||||||
* If <b>warn_obsolete</b> is set, warn about deprecated names. */
|
* If <b>warn_obsolete</b> is set, warn about deprecated names. */
|
||||||
static const char *
|
static const char *
|
||||||
expand_abbrev(config_format_t *fmt, const char *option, int command_line,
|
expand_abbrev(const config_format_t *fmt, const char *option, int command_line,
|
||||||
int warn_obsolete)
|
int warn_obsolete)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -1710,12 +1721,9 @@ config_free_lines(config_line_t *front)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** If <b>key</b> is a configuration option, return the corresponding
|
/** As config_find_option, but return a non-const pointer. */
|
||||||
* config_var_t. Otherwise, if <b>key</b> is a non-standard abbreviation,
|
|
||||||
* warn, and return the corresponding config_var_t. Otherwise return NULL.
|
|
||||||
*/
|
|
||||||
static config_var_t *
|
static config_var_t *
|
||||||
config_find_option(config_format_t *fmt, const char *key)
|
config_find_option_mutable(config_format_t *fmt, const char *key)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
size_t keylen = strlen(key);
|
size_t keylen = strlen(key);
|
||||||
@ -1740,9 +1748,20 @@ config_find_option(config_format_t *fmt, const char *key)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** If <b>key</b> is a configuration option, return the corresponding const
|
||||||
|
* config_var_t. Otherwise, if <b>key</b> is a non-standard abbreviation,
|
||||||
|
* warn, and return the corresponding const config_var_t. Otherwise return
|
||||||
|
* NULL.
|
||||||
|
*/
|
||||||
|
static const config_var_t *
|
||||||
|
config_find_option(const config_format_t *fmt, const char *key)
|
||||||
|
{
|
||||||
|
return config_find_option_mutable((config_format_t*)fmt, key);
|
||||||
|
}
|
||||||
|
|
||||||
/** Return the number of option entries in <b>fmt</b>. */
|
/** Return the number of option entries in <b>fmt</b>. */
|
||||||
static int
|
static int
|
||||||
config_count_options(config_format_t *fmt)
|
config_count_options(const config_format_t *fmt)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i=0; fmt->vars[i].name; ++i)
|
for (i=0; fmt->vars[i].name; ++i)
|
||||||
@ -1760,11 +1779,11 @@ config_count_options(config_format_t *fmt)
|
|||||||
* Called from config_assign_line() and option_reset().
|
* Called from config_assign_line() and option_reset().
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
config_assign_value(config_format_t *fmt, or_options_t *options,
|
config_assign_value(const config_format_t *fmt, or_options_t *options,
|
||||||
config_line_t *c, char **msg)
|
config_line_t *c, char **msg)
|
||||||
{
|
{
|
||||||
int i, ok;
|
int i, ok;
|
||||||
config_var_t *var;
|
const config_var_t *var;
|
||||||
void *lvalue;
|
void *lvalue;
|
||||||
|
|
||||||
CHECK(fmt, options);
|
CHECK(fmt, options);
|
||||||
@ -1926,11 +1945,11 @@ config_assign_value(config_format_t *fmt, or_options_t *options,
|
|||||||
* Called from config_assign().
|
* Called from config_assign().
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
config_assign_line(config_format_t *fmt, or_options_t *options,
|
config_assign_line(const config_format_t *fmt, or_options_t *options,
|
||||||
config_line_t *c, int use_defaults,
|
config_line_t *c, int use_defaults,
|
||||||
int clear_first, bitarray_t *options_seen, char **msg)
|
int clear_first, bitarray_t *options_seen, char **msg)
|
||||||
{
|
{
|
||||||
config_var_t *var;
|
const config_var_t *var;
|
||||||
|
|
||||||
CHECK(fmt, options);
|
CHECK(fmt, options);
|
||||||
|
|
||||||
@ -1991,10 +2010,10 @@ config_assign_line(config_format_t *fmt, or_options_t *options,
|
|||||||
/** Restore the option named <b>key</b> in options to its default value.
|
/** Restore the option named <b>key</b> in options to its default value.
|
||||||
* Called from config_assign(). */
|
* Called from config_assign(). */
|
||||||
static void
|
static void
|
||||||
config_reset_line(config_format_t *fmt, or_options_t *options,
|
config_reset_line(const config_format_t *fmt, or_options_t *options,
|
||||||
const char *key, int use_defaults)
|
const char *key, int use_defaults)
|
||||||
{
|
{
|
||||||
config_var_t *var;
|
const config_var_t *var;
|
||||||
|
|
||||||
CHECK(fmt, options);
|
CHECK(fmt, options);
|
||||||
|
|
||||||
@ -2009,7 +2028,7 @@ config_reset_line(config_format_t *fmt, or_options_t *options,
|
|||||||
int
|
int
|
||||||
option_is_recognized(const char *key)
|
option_is_recognized(const char *key)
|
||||||
{
|
{
|
||||||
config_var_t *var = config_find_option(&options_format, key);
|
const config_var_t *var = config_find_option(&options_format, key);
|
||||||
return (var != NULL);
|
return (var != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2018,14 +2037,14 @@ option_is_recognized(const char *key)
|
|||||||
const char *
|
const char *
|
||||||
option_get_canonical_name(const char *key)
|
option_get_canonical_name(const char *key)
|
||||||
{
|
{
|
||||||
config_var_t *var = config_find_option(&options_format, key);
|
const config_var_t *var = config_find_option(&options_format, key);
|
||||||
return var ? var->name : NULL;
|
return var ? var->name : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return a canonical list of the options assigned for key.
|
/** Return a canonical list of the options assigned for key.
|
||||||
*/
|
*/
|
||||||
config_line_t *
|
config_line_t *
|
||||||
option_get_assignment(or_options_t *options, const char *key)
|
option_get_assignment(const or_options_t *options, const char *key)
|
||||||
{
|
{
|
||||||
return get_assigned_option(&options_format, options, key, 1);
|
return get_assigned_option(&options_format, options, key, 1);
|
||||||
}
|
}
|
||||||
@ -2078,10 +2097,10 @@ config_lines_dup(const config_line_t *inp)
|
|||||||
* value needs to be quoted before it's put in a config file, quote and
|
* value needs to be quoted before it's put in a config file, quote and
|
||||||
* escape that value. Return NULL if no such key exists. */
|
* escape that value. Return NULL if no such key exists. */
|
||||||
static config_line_t *
|
static config_line_t *
|
||||||
get_assigned_option(config_format_t *fmt, void *options,
|
get_assigned_option(const config_format_t *fmt, const void *options,
|
||||||
const char *key, int escape_val)
|
const char *key, int escape_val)
|
||||||
{
|
{
|
||||||
config_var_t *var;
|
const config_var_t *var;
|
||||||
const void *value;
|
const void *value;
|
||||||
config_line_t *result;
|
config_line_t *result;
|
||||||
tor_assert(options && key);
|
tor_assert(options && key);
|
||||||
@ -2263,7 +2282,7 @@ options_trial_assign() calls config_assign(1, 1)
|
|||||||
returns.
|
returns.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
config_assign(config_format_t *fmt, void *options, config_line_t *list,
|
config_assign(const config_format_t *fmt, void *options, config_line_t *list,
|
||||||
int use_defaults, int clear_first, char **msg)
|
int use_defaults, int clear_first, char **msg)
|
||||||
{
|
{
|
||||||
config_line_t *p;
|
config_line_t *p;
|
||||||
@ -2325,7 +2344,7 @@ options_trial_assign(config_line_t *list, int use_defaults,
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options_validate(get_options(), trial_options, 1, msg) < 0) {
|
if (options_validate(get_options_mutable(), trial_options, 1, msg) < 0) {
|
||||||
config_free(&options_format, trial_options);
|
config_free(&options_format, trial_options);
|
||||||
return SETOPT_ERR_PARSE; /*XXX make this a separate return value. */
|
return SETOPT_ERR_PARSE; /*XXX make this a separate return value. */
|
||||||
}
|
}
|
||||||
@ -2347,7 +2366,8 @@ options_trial_assign(config_line_t *list, int use_defaults,
|
|||||||
/** Reset config option <b>var</b> to 0, 0.0, NULL, or the equivalent.
|
/** Reset config option <b>var</b> to 0, 0.0, NULL, or the equivalent.
|
||||||
* Called from option_reset() and config_free(). */
|
* Called from option_reset() and config_free(). */
|
||||||
static void
|
static void
|
||||||
option_clear(config_format_t *fmt, or_options_t *options, config_var_t *var)
|
option_clear(const config_format_t *fmt, or_options_t *options,
|
||||||
|
const const config_var_t *var)
|
||||||
{
|
{
|
||||||
void *lvalue = STRUCT_VAR_P(options, var->var_offset);
|
void *lvalue = STRUCT_VAR_P(options, var->var_offset);
|
||||||
(void)fmt; /* unused */
|
(void)fmt; /* unused */
|
||||||
@ -2405,8 +2425,8 @@ option_clear(config_format_t *fmt, or_options_t *options, config_var_t *var)
|
|||||||
* <b>use_defaults</b>, set it to its default value.
|
* <b>use_defaults</b>, set it to its default value.
|
||||||
* Called by config_init() and option_reset_line() and option_assign_line(). */
|
* Called by config_init() and option_reset_line() and option_assign_line(). */
|
||||||
static void
|
static void
|
||||||
option_reset(config_format_t *fmt, or_options_t *options,
|
option_reset(const config_format_t *fmt, or_options_t *options,
|
||||||
config_var_t *var, int use_defaults)
|
const config_var_t *var, int use_defaults)
|
||||||
{
|
{
|
||||||
config_line_t *c;
|
config_line_t *c;
|
||||||
char *msg = NULL;
|
char *msg = NULL;
|
||||||
@ -2446,7 +2466,7 @@ list_torrc_options(void)
|
|||||||
int i;
|
int i;
|
||||||
smartlist_t *lines = smartlist_create();
|
smartlist_t *lines = smartlist_create();
|
||||||
for (i = 0; _option_vars[i].name; ++i) {
|
for (i = 0; _option_vars[i].name; ++i) {
|
||||||
config_var_t *var = &_option_vars[i];
|
const config_var_t *var = &_option_vars[i];
|
||||||
if (var->type == CONFIG_TYPE_OBSOLETE ||
|
if (var->type == CONFIG_TYPE_OBSOLETE ||
|
||||||
var->type == CONFIG_TYPE_LINELIST_V)
|
var->type == CONFIG_TYPE_LINELIST_V)
|
||||||
continue;
|
continue;
|
||||||
@ -2465,7 +2485,7 @@ static uint32_t last_resolved_addr = 0;
|
|||||||
* public IP address.
|
* public IP address.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
resolve_my_address(int warn_severity, or_options_t *options,
|
resolve_my_address(int warn_severity, const or_options_t *options,
|
||||||
uint32_t *addr_out, char **hostname_out)
|
uint32_t *addr_out, char **hostname_out)
|
||||||
{
|
{
|
||||||
struct in_addr in;
|
struct in_addr in;
|
||||||
@ -2641,7 +2661,7 @@ is_local_addr(const tor_addr_t *addr)
|
|||||||
|
|
||||||
/** Release storage held by <b>options</b>. */
|
/** Release storage held by <b>options</b>. */
|
||||||
static void
|
static void
|
||||||
config_free(config_format_t *fmt, void *options)
|
config_free(const config_format_t *fmt, void *options)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -2680,8 +2700,9 @@ config_lines_eq(config_line_t *a, config_line_t *b)
|
|||||||
* and <b>o2</b>. Must not be called for LINELIST_S or OBSOLETE options.
|
* and <b>o2</b>. Must not be called for LINELIST_S or OBSOLETE options.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
option_is_same(config_format_t *fmt,
|
option_is_same(const config_format_t *fmt,
|
||||||
or_options_t *o1, or_options_t *o2, const char *name)
|
const or_options_t *o1, const or_options_t *o2,
|
||||||
|
const char *name)
|
||||||
{
|
{
|
||||||
config_line_t *c1, *c2;
|
config_line_t *c1, *c2;
|
||||||
int r = 1;
|
int r = 1;
|
||||||
@ -2698,7 +2719,7 @@ option_is_same(config_format_t *fmt,
|
|||||||
|
|
||||||
/** Copy storage held by <b>old</b> into a new or_options_t and return it. */
|
/** Copy storage held by <b>old</b> into a new or_options_t and return it. */
|
||||||
static or_options_t *
|
static or_options_t *
|
||||||
options_dup(config_format_t *fmt, or_options_t *old)
|
options_dup(const config_format_t *fmt, const or_options_t *old)
|
||||||
{
|
{
|
||||||
or_options_t *newopts;
|
or_options_t *newopts;
|
||||||
int i;
|
int i;
|
||||||
@ -2774,10 +2795,10 @@ is_listening_on_low_port(int port_option,
|
|||||||
/** Set all vars in the configuration object <b>options</b> to their default
|
/** Set all vars in the configuration object <b>options</b> to their default
|
||||||
* values. */
|
* values. */
|
||||||
static void
|
static void
|
||||||
config_init(config_format_t *fmt, void *options)
|
config_init(const config_format_t *fmt, void *options)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
config_var_t *var;
|
const config_var_t *var;
|
||||||
CHECK(fmt, options);
|
CHECK(fmt, options);
|
||||||
|
|
||||||
for (i=0; fmt->vars[i].name; ++i) {
|
for (i=0; fmt->vars[i].name; ++i) {
|
||||||
@ -2793,7 +2814,7 @@ config_init(config_format_t *fmt, void *options)
|
|||||||
* Else, if comment_defaults, write default values as comments.
|
* Else, if comment_defaults, write default values as comments.
|
||||||
*/
|
*/
|
||||||
static char *
|
static char *
|
||||||
config_dump(config_format_t *fmt, void *options, int minimal,
|
config_dump(const config_format_t *fmt, const void *options, int minimal,
|
||||||
int comment_defaults)
|
int comment_defaults)
|
||||||
{
|
{
|
||||||
smartlist_t *elements;
|
smartlist_t *elements;
|
||||||
@ -2861,7 +2882,7 @@ config_dump(config_format_t *fmt, void *options, int minimal,
|
|||||||
* include options that are the same as Tor's defaults.
|
* include options that are the same as Tor's defaults.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
options_dump(or_options_t *options, int minimal)
|
options_dump(const or_options_t *options, int minimal)
|
||||||
{
|
{
|
||||||
return config_dump(&options_format, options, minimal, 0);
|
return config_dump(&options_format, options, minimal, 0);
|
||||||
}
|
}
|
||||||
@ -3862,7 +3883,8 @@ opt_streq(const char *s1, const char *s2)
|
|||||||
|
|
||||||
/** Check if any of the previous options have changed but aren't allowed to. */
|
/** Check if any of the previous options have changed but aren't allowed to. */
|
||||||
static int
|
static int
|
||||||
options_transition_allowed(or_options_t *old, or_options_t *new_val,
|
options_transition_allowed(const or_options_t *old,
|
||||||
|
const or_options_t *new_val,
|
||||||
char **msg)
|
char **msg)
|
||||||
{
|
{
|
||||||
if (!old)
|
if (!old)
|
||||||
@ -3918,8 +3940,8 @@ options_transition_allowed(or_options_t *old, or_options_t *new_val,
|
|||||||
/** Return 1 if any change from <b>old_options</b> to <b>new_options</b>
|
/** Return 1 if any change from <b>old_options</b> to <b>new_options</b>
|
||||||
* will require us to rotate the CPU and DNS workers; else return 0. */
|
* will require us to rotate the CPU and DNS workers; else return 0. */
|
||||||
static int
|
static int
|
||||||
options_transition_affects_workers(or_options_t *old_options,
|
options_transition_affects_workers(const or_options_t *old_options,
|
||||||
or_options_t *new_options)
|
const or_options_t *new_options)
|
||||||
{
|
{
|
||||||
if (!opt_streq(old_options->DataDirectory, new_options->DataDirectory) ||
|
if (!opt_streq(old_options->DataDirectory, new_options->DataDirectory) ||
|
||||||
old_options->NumCPUs != new_options->NumCPUs ||
|
old_options->NumCPUs != new_options->NumCPUs ||
|
||||||
@ -3942,8 +3964,8 @@ options_transition_affects_workers(or_options_t *old_options,
|
|||||||
/** Return 1 if any change from <b>old_options</b> to <b>new_options</b>
|
/** Return 1 if any change from <b>old_options</b> to <b>new_options</b>
|
||||||
* will require us to generate a new descriptor; else return 0. */
|
* will require us to generate a new descriptor; else return 0. */
|
||||||
static int
|
static int
|
||||||
options_transition_affects_descriptor(or_options_t *old_options,
|
options_transition_affects_descriptor(const or_options_t *old_options,
|
||||||
or_options_t *new_options)
|
const or_options_t *new_options)
|
||||||
{
|
{
|
||||||
/* XXX We can be smarter here. If your DirPort isn't being
|
/* XXX We can be smarter here. If your DirPort isn't being
|
||||||
* published and you just turned it off, no need to republish. Etc. */
|
* published and you just turned it off, no need to republish. Etc. */
|
||||||
@ -4309,9 +4331,9 @@ options_init_from_string(const char *cf,
|
|||||||
/* Change defaults. */
|
/* Change defaults. */
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; testing_tor_network_defaults[i].name; ++i) {
|
for (i = 0; testing_tor_network_defaults[i].name; ++i) {
|
||||||
config_var_t *new_var = &testing_tor_network_defaults[i];
|
const config_var_t *new_var = &testing_tor_network_defaults[i];
|
||||||
config_var_t *old_var =
|
config_var_t *old_var =
|
||||||
config_find_option(&options_format, new_var->name);
|
config_find_option_mutable(&options_format, new_var->name);
|
||||||
tor_assert(new_var);
|
tor_assert(new_var);
|
||||||
tor_assert(old_var);
|
tor_assert(old_var);
|
||||||
old_var->initvalue = new_var->initvalue;
|
old_var->initvalue = new_var->initvalue;
|
||||||
@ -4388,7 +4410,7 @@ get_torrc_fname(void)
|
|||||||
* configuration <b>options</b>
|
* configuration <b>options</b>
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
config_register_addressmaps(or_options_t *options)
|
config_register_addressmaps(const or_options_t *options)
|
||||||
{
|
{
|
||||||
smartlist_t *elts;
|
smartlist_t *elts;
|
||||||
config_line_t *opt;
|
config_line_t *opt;
|
||||||
@ -4818,7 +4840,7 @@ validate_data_directory(or_options_t *options)
|
|||||||
* doesn't begin with GENERATED_FILE_PREFIX, rename it. Otherwise
|
* doesn't begin with GENERATED_FILE_PREFIX, rename it. Otherwise
|
||||||
* replace it. Return 0 on success, -1 on failure. */
|
* replace it. Return 0 on success, -1 on failure. */
|
||||||
static int
|
static int
|
||||||
write_configuration_file(const char *fname, or_options_t *options)
|
write_configuration_file(const char *fname, const or_options_t *options)
|
||||||
{
|
{
|
||||||
char *old_val=NULL, *new_val=NULL, *new_conf=NULL;
|
char *old_val=NULL, *new_val=NULL, *new_conf=NULL;
|
||||||
int rename_old = 0, r;
|
int rename_old = 0, r;
|
||||||
@ -5155,7 +5177,7 @@ get_or_state(void)
|
|||||||
* Note: Consider using the get_datadir_fname* macros in or.h.
|
* Note: Consider using the get_datadir_fname* macros in or.h.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
options_get_datadir_fname2_suffix(or_options_t *options,
|
options_get_datadir_fname2_suffix(const or_options_t *options,
|
||||||
const char *sub1, const char *sub2,
|
const char *sub1, const char *sub2,
|
||||||
const char *suffix)
|
const char *suffix)
|
||||||
{
|
{
|
||||||
@ -5472,7 +5494,7 @@ getinfo_helper_config(control_connection_t *conn,
|
|||||||
smartlist_t *sl = smartlist_create();
|
smartlist_t *sl = smartlist_create();
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; _option_vars[i].name; ++i) {
|
for (i = 0; _option_vars[i].name; ++i) {
|
||||||
config_var_t *var = &_option_vars[i];
|
const config_var_t *var = &_option_vars[i];
|
||||||
const char *type;
|
const char *type;
|
||||||
char *line;
|
char *line;
|
||||||
switch (var->type) {
|
switch (var->type) {
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
#define _TOR_CONFIG_H
|
#define _TOR_CONFIG_H
|
||||||
|
|
||||||
const char *get_dirportfrontpage(void);
|
const char *get_dirportfrontpage(void);
|
||||||
or_options_t *get_options(void);
|
const or_options_t *get_options(void);
|
||||||
|
or_options_t *get_options_mutable(void);
|
||||||
int set_options(or_options_t *new_val, char **msg);
|
int set_options(or_options_t *new_val, char **msg);
|
||||||
void config_free_all(void);
|
void config_free_all(void);
|
||||||
const char *safe_str_client(const char *address);
|
const char *safe_str_client(const char *address);
|
||||||
@ -26,21 +27,21 @@ int config_get_lines(const char *string, config_line_t **result);
|
|||||||
void config_free_lines(config_line_t *front);
|
void config_free_lines(config_line_t *front);
|
||||||
setopt_err_t options_trial_assign(config_line_t *list, int use_defaults,
|
setopt_err_t options_trial_assign(config_line_t *list, int use_defaults,
|
||||||
int clear_first, char **msg);
|
int clear_first, char **msg);
|
||||||
int resolve_my_address(int warn_severity, or_options_t *options,
|
int resolve_my_address(int warn_severity, const or_options_t *options,
|
||||||
uint32_t *addr, char **hostname_out);
|
uint32_t *addr, char **hostname_out);
|
||||||
int is_local_addr(const tor_addr_t *addr) ATTR_PURE;
|
int is_local_addr(const tor_addr_t *addr) ATTR_PURE;
|
||||||
void options_init(or_options_t *options);
|
void options_init(or_options_t *options);
|
||||||
char *options_dump(or_options_t *options, int minimal);
|
char *options_dump(const or_options_t *options, int minimal);
|
||||||
int options_init_from_torrc(int argc, char **argv);
|
int options_init_from_torrc(int argc, char **argv);
|
||||||
setopt_err_t options_init_from_string(const char *cf,
|
setopt_err_t options_init_from_string(const char *cf,
|
||||||
int command, const char *command_arg, char **msg);
|
int command, const char *command_arg, char **msg);
|
||||||
int option_is_recognized(const char *key);
|
int option_is_recognized(const char *key);
|
||||||
const char *option_get_canonical_name(const char *key);
|
const char *option_get_canonical_name(const char *key);
|
||||||
config_line_t *option_get_assignment(or_options_t *options,
|
config_line_t *option_get_assignment(const or_options_t *options,
|
||||||
const char *key);
|
const char *key);
|
||||||
int options_save_current(void);
|
int options_save_current(void);
|
||||||
const char *get_torrc_fname(void);
|
const char *get_torrc_fname(void);
|
||||||
char *options_get_datadir_fname2_suffix(or_options_t *options,
|
char *options_get_datadir_fname2_suffix(const or_options_t *options,
|
||||||
const char *sub1, const char *sub2,
|
const char *sub1, const char *sub2,
|
||||||
const char *suffix);
|
const char *suffix);
|
||||||
#define get_datadir_fname2_suffix(sub1, sub2, suffix) \
|
#define get_datadir_fname2_suffix(sub1, sub2, suffix) \
|
||||||
@ -63,14 +64,15 @@ or_state_t *get_or_state(void);
|
|||||||
int did_last_state_file_write_fail(void);
|
int did_last_state_file_write_fail(void);
|
||||||
int or_state_save(time_t now);
|
int or_state_save(time_t now);
|
||||||
|
|
||||||
int options_need_geoip_info(or_options_t *options, const char **reason_out);
|
int options_need_geoip_info(const or_options_t *options,
|
||||||
|
const char **reason_out);
|
||||||
int getinfo_helper_config(control_connection_t *conn,
|
int getinfo_helper_config(control_connection_t *conn,
|
||||||
const char *question, char **answer,
|
const char *question, char **answer,
|
||||||
const char **errmsg);
|
const char **errmsg);
|
||||||
|
|
||||||
const char *tor_get_digests(void);
|
const char *tor_get_digests(void);
|
||||||
uint32_t get_effective_bwrate(or_options_t *options);
|
uint32_t get_effective_bwrate(const or_options_t *options);
|
||||||
uint32_t get_effective_bwburst(or_options_t *options);
|
uint32_t get_effective_bwburst(const or_options_t *options);
|
||||||
|
|
||||||
#ifdef CONFIG_PRIVATE
|
#ifdef CONFIG_PRIVATE
|
||||||
/* Used only by config.c and test.c */
|
/* Used only by config.c and test.c */
|
||||||
|
@ -619,7 +619,7 @@ connection_about_to_close_connection(connection_t *conn)
|
|||||||
circuit_n_conn_done(TO_OR_CONN(conn), 0);
|
circuit_n_conn_done(TO_OR_CONN(conn), 0);
|
||||||
/* now mark things down as needed */
|
/* now mark things down as needed */
|
||||||
if (connection_or_nonopen_was_started_here(or_conn)) {
|
if (connection_or_nonopen_was_started_here(or_conn)) {
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
rep_hist_note_connect_failed(or_conn->identity_digest, now);
|
rep_hist_note_connect_failed(or_conn->identity_digest, now);
|
||||||
entry_guard_register_connect_status(or_conn->identity_digest,0,
|
entry_guard_register_connect_status(or_conn->identity_digest,0,
|
||||||
!options->HTTPSProxy, now);
|
!options->HTTPSProxy, now);
|
||||||
@ -899,7 +899,7 @@ warn_too_many_conns(void)
|
|||||||
/** Check whether we should be willing to open an AF_UNIX socket in
|
/** Check whether we should be willing to open an AF_UNIX socket in
|
||||||
* <b>path</b>. Return 0 if we should go ahead and -1 if we shouldn't. */
|
* <b>path</b>. Return 0 if we should go ahead and -1 if we shouldn't. */
|
||||||
static int
|
static int
|
||||||
check_location_for_unix_socket(or_options_t *options, const char *path)
|
check_location_for_unix_socket(const or_options_t *options, const char *path)
|
||||||
{
|
{
|
||||||
int r = -1;
|
int r = -1;
|
||||||
char *p = tor_strdup(path);
|
char *p = tor_strdup(path);
|
||||||
@ -1186,7 +1186,7 @@ connection_handle_listener_read(connection_t *conn, int new_type)
|
|||||||
struct sockaddr *remote = (struct sockaddr*)addrbuf;
|
struct sockaddr *remote = (struct sockaddr*)addrbuf;
|
||||||
/* length of the remote address. Must be whatever accept() needs. */
|
/* length of the remote address. Must be whatever accept() needs. */
|
||||||
socklen_t remotelen = (socklen_t)sizeof(addrbuf);
|
socklen_t remotelen = (socklen_t)sizeof(addrbuf);
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
tor_assert((size_t)remotelen >= sizeof(struct sockaddr_in));
|
tor_assert((size_t)remotelen >= sizeof(struct sockaddr_in));
|
||||||
memset(addrbuf, 0, sizeof(addrbuf));
|
memset(addrbuf, 0, sizeof(addrbuf));
|
||||||
@ -1366,7 +1366,7 @@ connection_connect(connection_t *conn, const char *address,
|
|||||||
char addrbuf[256];
|
char addrbuf[256];
|
||||||
struct sockaddr *dest_addr;
|
struct sockaddr *dest_addr;
|
||||||
int dest_addr_len;
|
int dest_addr_len;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
int protocol_family;
|
int protocol_family;
|
||||||
|
|
||||||
if (get_n_open_sockets() >= get_options()->_ConnLimit-1) {
|
if (get_n_open_sockets() >= get_options()->_ConnLimit-1) {
|
||||||
@ -1489,7 +1489,7 @@ connection_proxy_state_to_string(int state)
|
|||||||
int
|
int
|
||||||
connection_proxy_connect(connection_t *conn, int type)
|
connection_proxy_connect(connection_t *conn, int type)
|
||||||
{
|
{
|
||||||
or_options_t *options;
|
const or_options_t *options;
|
||||||
|
|
||||||
tor_assert(conn);
|
tor_assert(conn);
|
||||||
|
|
||||||
@ -2005,7 +2005,7 @@ int
|
|||||||
retry_all_listeners(smartlist_t *replaced_conns,
|
retry_all_listeners(smartlist_t *replaced_conns,
|
||||||
smartlist_t *new_conns)
|
smartlist_t *new_conns)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
const uint16_t old_or_port = router_get_advertised_or_port(options);
|
const uint16_t old_or_port = router_get_advertised_or_port(options);
|
||||||
const uint16_t old_dir_port = router_get_advertised_dir_port(options, 0);
|
const uint16_t old_dir_port = router_get_advertised_dir_port(options, 0);
|
||||||
@ -2071,7 +2071,7 @@ retry_all_listeners(smartlist_t *replaced_conns,
|
|||||||
static int
|
static int
|
||||||
connection_is_rate_limited(connection_t *conn)
|
connection_is_rate_limited(connection_t *conn)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
if (conn->linked)
|
if (conn->linked)
|
||||||
return 0; /* Internal connection */
|
return 0; /* Internal connection */
|
||||||
else if (! options->CountPrivateBandwidth &&
|
else if (! options->CountPrivateBandwidth &&
|
||||||
@ -2269,7 +2269,7 @@ global_write_bucket_low(connection_t *conn, size_t attempt, int priority)
|
|||||||
|
|
||||||
if (priority == 1) { /* old-style v1 query */
|
if (priority == 1) { /* old-style v1 query */
|
||||||
/* Could we handle *two* of these requests within the next two seconds? */
|
/* Could we handle *two* of these requests within the next two seconds? */
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
int64_t can_write = (int64_t)smaller_bucket
|
int64_t can_write = (int64_t)smaller_bucket
|
||||||
+ 2*(options->RelayBandwidthRate ? options->RelayBandwidthRate :
|
+ 2*(options->RelayBandwidthRate ? options->RelayBandwidthRate :
|
||||||
options->BandwidthRate);
|
options->BandwidthRate);
|
||||||
@ -2387,7 +2387,7 @@ connection_consider_empty_write_buckets(connection_t *conn)
|
|||||||
void
|
void
|
||||||
connection_bucket_init(void)
|
connection_bucket_init(void)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
/* start it at max traffic */
|
/* start it at max traffic */
|
||||||
global_read_bucket = (int)options->BandwidthBurst;
|
global_read_bucket = (int)options->BandwidthBurst;
|
||||||
global_write_bucket = (int)options->BandwidthBurst;
|
global_write_bucket = (int)options->BandwidthBurst;
|
||||||
@ -2432,7 +2432,7 @@ connection_bucket_refill_helper(int *bucket, int rate, int burst,
|
|||||||
void
|
void
|
||||||
connection_bucket_refill(int seconds_elapsed, time_t now)
|
connection_bucket_refill(int seconds_elapsed, time_t now)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
smartlist_t *conns = get_connection_array();
|
smartlist_t *conns = get_connection_array();
|
||||||
int relayrate, relayburst;
|
int relayrate, relayburst;
|
||||||
|
|
||||||
@ -2552,7 +2552,7 @@ connection_bucket_refill(int seconds_elapsed, time_t now)
|
|||||||
void
|
void
|
||||||
connection_bucket_init(void)
|
connection_bucket_init(void)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
const struct timeval *tick = tor_libevent_get_one_tick_timeout();
|
const struct timeval *tick = tor_libevent_get_one_tick_timeout();
|
||||||
struct ev_token_bucket_cfg *bucket_cfg;
|
struct ev_token_bucket_cfg *bucket_cfg;
|
||||||
|
|
||||||
|
@ -439,7 +439,7 @@ connection_ap_expire_beginning(void)
|
|||||||
edge_connection_t *conn;
|
edge_connection_t *conn;
|
||||||
circuit_t *circ;
|
circuit_t *circ;
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
int severity;
|
int severity;
|
||||||
int cutoff;
|
int cutoff;
|
||||||
int seconds_idle, seconds_since_born;
|
int seconds_idle, seconds_since_born;
|
||||||
@ -813,7 +813,7 @@ clear_trackexithost_mappings(const char *exitname)
|
|||||||
* host is unknown or no longer allowed, or for which the source address
|
* host is unknown or no longer allowed, or for which the source address
|
||||||
* is no longer in trackexithosts. */
|
* is no longer in trackexithosts. */
|
||||||
void
|
void
|
||||||
addressmap_clear_excluded_trackexithosts(or_options_t *options)
|
addressmap_clear_excluded_trackexithosts(const or_options_t *options)
|
||||||
{
|
{
|
||||||
const routerset_t *allow_nodes = options->ExitNodes;
|
const routerset_t *allow_nodes = options->ExitNodes;
|
||||||
const routerset_t *exclude_nodes = options->_ExcludeExitNodesUnion;
|
const routerset_t *exclude_nodes = options->_ExcludeExitNodesUnion;
|
||||||
@ -866,7 +866,7 @@ addressmap_clear_excluded_trackexithosts(or_options_t *options)
|
|||||||
* no longer allowed by AutomapHostsOnResolve, or for which the
|
* no longer allowed by AutomapHostsOnResolve, or for which the
|
||||||
* target address is no longer in the virtual network. */
|
* target address is no longer in the virtual network. */
|
||||||
void
|
void
|
||||||
addressmap_clear_invalid_automaps(or_options_t *options)
|
addressmap_clear_invalid_automaps(const or_options_t *options)
|
||||||
{
|
{
|
||||||
int clear_all = !options->AutomapHostsOnResolve;
|
int clear_all = !options->AutomapHostsOnResolve;
|
||||||
const smartlist_t *suffixes = options->AutomapHostsSuffixes;
|
const smartlist_t *suffixes = options->AutomapHostsSuffixes;
|
||||||
@ -1520,7 +1520,7 @@ addressmap_get_mappings(smartlist_t *sl, time_t min_expires,
|
|||||||
static int
|
static int
|
||||||
consider_plaintext_ports(edge_connection_t *conn, uint16_t port)
|
consider_plaintext_ports(edge_connection_t *conn, uint16_t port)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
int reject = smartlist_string_num_isin(options->RejectPlaintextPorts, port);
|
int reject = smartlist_string_num_isin(options->RejectPlaintextPorts, port);
|
||||||
|
|
||||||
if (smartlist_string_num_isin(options->WarnPlaintextPorts, port)) {
|
if (smartlist_string_num_isin(options->WarnPlaintextPorts, port)) {
|
||||||
@ -1557,7 +1557,7 @@ connection_ap_rewrite_and_attach_if_allowed(edge_connection_t *conn,
|
|||||||
origin_circuit_t *circ,
|
origin_circuit_t *circ,
|
||||||
crypt_path_t *cpath)
|
crypt_path_t *cpath)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
if (options->LeaveStreamsUnattached) {
|
if (options->LeaveStreamsUnattached) {
|
||||||
conn->_base.state = AP_CONN_STATE_CONTROLLER_WAIT;
|
conn->_base.state = AP_CONN_STATE_CONTROLLER_WAIT;
|
||||||
@ -1588,7 +1588,7 @@ connection_ap_handshake_rewrite_and_attach(edge_connection_t *conn,
|
|||||||
{
|
{
|
||||||
socks_request_t *socks = conn->socks_request;
|
socks_request_t *socks = conn->socks_request;
|
||||||
hostname_type_t addresstype;
|
hostname_type_t addresstype;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
struct in_addr addr_tmp;
|
struct in_addr addr_tmp;
|
||||||
/* We set this to true if this is an address we should automatically
|
/* We set this to true if this is an address we should automatically
|
||||||
* remap to a local address in VirtualAddrNetwork */
|
* remap to a local address in VirtualAddrNetwork */
|
||||||
@ -2079,7 +2079,7 @@ connection_ap_handshake_process_socks(edge_connection_t *conn)
|
|||||||
{
|
{
|
||||||
socks_request_t *socks;
|
socks_request_t *socks;
|
||||||
int sockshere;
|
int sockshere;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
tor_assert(conn);
|
tor_assert(conn);
|
||||||
tor_assert(conn->_base.type == CONN_TYPE_AP);
|
tor_assert(conn->_base.type == CONN_TYPE_AP);
|
||||||
@ -2703,7 +2703,7 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
|
|||||||
char *address=NULL;
|
char *address=NULL;
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
or_circuit_t *or_circ = NULL;
|
or_circuit_t *or_circ = NULL;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
assert_circuit_ok(circ);
|
assert_circuit_ok(circ);
|
||||||
if (!CIRCUIT_IS_ORIGIN(circ))
|
if (!CIRCUIT_IS_ORIGIN(circ))
|
||||||
@ -3104,7 +3104,7 @@ connection_edge_is_rendezvous_stream(edge_connection_t *conn)
|
|||||||
int
|
int
|
||||||
connection_ap_can_use_exit(edge_connection_t *conn, const node_t *exit)
|
connection_ap_can_use_exit(edge_connection_t *conn, const node_t *exit)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
tor_assert(conn);
|
tor_assert(conn);
|
||||||
tor_assert(conn->_base.type == CONN_TYPE_AP);
|
tor_assert(conn->_base.type == CONN_TYPE_AP);
|
||||||
|
@ -63,8 +63,8 @@ int connection_ap_process_transparent(edge_connection_t *conn);
|
|||||||
int address_is_invalid_destination(const char *address, int client);
|
int address_is_invalid_destination(const char *address, int client);
|
||||||
|
|
||||||
void addressmap_init(void);
|
void addressmap_init(void);
|
||||||
void addressmap_clear_excluded_trackexithosts(or_options_t *options);
|
void addressmap_clear_excluded_trackexithosts(const or_options_t *options);
|
||||||
void addressmap_clear_invalid_automaps(or_options_t *options);
|
void addressmap_clear_invalid_automaps(const or_options_t *options);
|
||||||
void addressmap_clean(time_t now);
|
void addressmap_clean(time_t now);
|
||||||
void addressmap_clear_configured(void);
|
void addressmap_clear_configured(void);
|
||||||
void addressmap_clear_transient(void);
|
void addressmap_clear_transient(void);
|
||||||
|
@ -380,7 +380,7 @@ connection_or_digest_is_known_relay(const char *id_digest)
|
|||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
connection_or_update_token_buckets_helper(or_connection_t *conn, int reset,
|
connection_or_update_token_buckets_helper(or_connection_t *conn, int reset,
|
||||||
or_options_t *options)
|
const or_options_t *options)
|
||||||
{
|
{
|
||||||
int rate, burst; /* per-connection rate limiting params */
|
int rate, burst; /* per-connection rate limiting params */
|
||||||
if (connection_or_digest_is_known_relay(conn->identity_digest)) {
|
if (connection_or_digest_is_known_relay(conn->identity_digest)) {
|
||||||
@ -436,7 +436,8 @@ connection_or_update_token_buckets_helper(or_connection_t *conn, int reset,
|
|||||||
* Go through all the OR connections and update their token buckets to make
|
* Go through all the OR connections and update their token buckets to make
|
||||||
* sure they don't exceed their maximum values. */
|
* sure they don't exceed their maximum values. */
|
||||||
void
|
void
|
||||||
connection_or_update_token_buckets(smartlist_t *conns, or_options_t *options)
|
connection_or_update_token_buckets(smartlist_t *conns,
|
||||||
|
const or_options_t *options)
|
||||||
{
|
{
|
||||||
SMARTLIST_FOREACH(conns, connection_t *, conn,
|
SMARTLIST_FOREACH(conns, connection_t *, conn,
|
||||||
{
|
{
|
||||||
@ -827,7 +828,7 @@ connection_or_connect(const tor_addr_t *_addr, uint16_t port,
|
|||||||
const char *id_digest)
|
const char *id_digest)
|
||||||
{
|
{
|
||||||
or_connection_t *conn;
|
or_connection_t *conn;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
int socket_error = 0;
|
int socket_error = 0;
|
||||||
int using_proxy = 0;
|
int using_proxy = 0;
|
||||||
tor_addr_t addr;
|
tor_addr_t addr;
|
||||||
@ -1144,7 +1145,7 @@ connection_or_check_valid_tls_handshake(or_connection_t *conn,
|
|||||||
char *digest_rcvd_out)
|
char *digest_rcvd_out)
|
||||||
{
|
{
|
||||||
crypto_pk_env_t *identity_rcvd=NULL;
|
crypto_pk_env_t *identity_rcvd=NULL;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
int severity = server_mode(options) ? LOG_PROTOCOL_WARN : LOG_WARN;
|
int severity = server_mode(options) ? LOG_PROTOCOL_WARN : LOG_WARN;
|
||||||
const char *safe_address =
|
const char *safe_address =
|
||||||
started_here ? conn->_base.address :
|
started_here ? conn->_base.address :
|
||||||
|
@ -27,7 +27,7 @@ int connection_or_finished_flushing(or_connection_t *conn);
|
|||||||
int connection_or_finished_connecting(or_connection_t *conn);
|
int connection_or_finished_connecting(or_connection_t *conn);
|
||||||
int connection_or_digest_is_known_relay(const char *id_digest);
|
int connection_or_digest_is_known_relay(const char *id_digest);
|
||||||
void connection_or_update_token_buckets(smartlist_t *conns,
|
void connection_or_update_token_buckets(smartlist_t *conns,
|
||||||
or_options_t *options);
|
const or_options_t *options);
|
||||||
|
|
||||||
void connection_or_connect_failed(or_connection_t *conn,
|
void connection_or_connect_failed(or_connection_t *conn,
|
||||||
int reason, const char *msg);
|
int reason, const char *msg);
|
||||||
|
@ -523,7 +523,7 @@ control_ports_write_to_file(void)
|
|||||||
{
|
{
|
||||||
smartlist_t *lines;
|
smartlist_t *lines;
|
||||||
char *joined = NULL;
|
char *joined = NULL;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
if (!options->ControlPortWriteToFile)
|
if (!options->ControlPortWriteToFile)
|
||||||
return;
|
return;
|
||||||
@ -827,7 +827,7 @@ handle_control_getconf(control_connection_t *conn, uint32_t body_len,
|
|||||||
smartlist_t *unrecognized = smartlist_create();
|
smartlist_t *unrecognized = smartlist_create();
|
||||||
char *msg = NULL;
|
char *msg = NULL;
|
||||||
size_t msg_len;
|
size_t msg_len;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
int i, len;
|
int i, len;
|
||||||
|
|
||||||
(void) body_len; /* body is NUL-terminated; so we can ignore len. */
|
(void) body_len; /* body is NUL-terminated; so we can ignore len. */
|
||||||
@ -1070,7 +1070,7 @@ handle_control_authenticate(control_connection_t *conn, uint32_t len,
|
|||||||
const char *body)
|
const char *body)
|
||||||
{
|
{
|
||||||
int used_quoted_string = 0;
|
int used_quoted_string = 0;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
const char *errstr = NULL;
|
const char *errstr = NULL;
|
||||||
char *password;
|
char *password;
|
||||||
size_t password_len;
|
size_t password_len;
|
||||||
@ -2849,7 +2849,7 @@ handle_control_protocolinfo(control_connection_t *conn, uint32_t len,
|
|||||||
connection_mark_for_close(TO_CONN(conn));
|
connection_mark_for_close(TO_CONN(conn));
|
||||||
goto done;
|
goto done;
|
||||||
} else {
|
} else {
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
int cookies = options->CookieAuthentication;
|
int cookies = options->CookieAuthentication;
|
||||||
char *cfile = get_cookie_file();
|
char *cfile = get_cookie_file();
|
||||||
char *esc_cfile = esc_for_log(cfile);
|
char *esc_cfile = esc_for_log(cfile);
|
||||||
@ -4021,7 +4021,7 @@ control_event_guard(const char *nickname, const char *digest,
|
|||||||
static char *
|
static char *
|
||||||
get_cookie_file(void)
|
get_cookie_file(void)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
if (options->CookieAuthFile && strlen(options->CookieAuthFile)) {
|
if (options->CookieAuthFile && strlen(options->CookieAuthFile)) {
|
||||||
return tor_strdup(options->CookieAuthFile);
|
return tor_strdup(options->CookieAuthFile);
|
||||||
} else {
|
} else {
|
||||||
|
@ -252,7 +252,7 @@ int
|
|||||||
directories_have_accepted_server_descriptor(void)
|
directories_have_accepted_server_descriptor(void)
|
||||||
{
|
{
|
||||||
smartlist_t *servers = router_get_trusted_dir_servers();
|
smartlist_t *servers = router_get_trusted_dir_servers();
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
SMARTLIST_FOREACH(servers, trusted_dir_server_t *, d, {
|
SMARTLIST_FOREACH(servers, trusted_dir_server_t *, d, {
|
||||||
if ((d->type & options->_PublishServerDescriptor) &&
|
if ((d->type & options->_PublishServerDescriptor) &&
|
||||||
d->has_accepted_serverdesc) {
|
d->has_accepted_serverdesc) {
|
||||||
@ -285,7 +285,7 @@ directory_post_to_dirservers(uint8_t dir_purpose, uint8_t router_purpose,
|
|||||||
const char *payload,
|
const char *payload,
|
||||||
size_t payload_len, size_t extrainfo_len)
|
size_t payload_len, size_t extrainfo_len)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
int post_via_tor;
|
int post_via_tor;
|
||||||
smartlist_t *dirservers = router_get_trusted_dir_servers();
|
smartlist_t *dirservers = router_get_trusted_dir_servers();
|
||||||
int found = 0;
|
int found = 0;
|
||||||
@ -352,7 +352,7 @@ directory_get_from_dirserver(uint8_t dir_purpose, uint8_t router_purpose,
|
|||||||
const char *resource, int pds_flags)
|
const char *resource, int pds_flags)
|
||||||
{
|
{
|
||||||
const routerstatus_t *rs = NULL;
|
const routerstatus_t *rs = NULL;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
int prefer_authority = directory_fetches_from_authorities(options);
|
int prefer_authority = directory_fetches_from_authorities(options);
|
||||||
int get_via_tor = purpose_needs_anonymity(dir_purpose, router_purpose);
|
int get_via_tor = purpose_needs_anonymity(dir_purpose, router_purpose);
|
||||||
dirinfo_type_t type;
|
dirinfo_type_t type;
|
||||||
@ -548,7 +548,7 @@ directory_initiate_command_routerstatus_rend(const routerstatus_t *status,
|
|||||||
time_t if_modified_since,
|
time_t if_modified_since,
|
||||||
const rend_data_t *rend_query)
|
const rend_data_t *rend_query)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
const node_t *node;
|
const node_t *node;
|
||||||
char address_buf[INET_NTOA_BUF_LEN+1];
|
char address_buf[INET_NTOA_BUF_LEN+1];
|
||||||
struct in_addr in;
|
struct in_addr in;
|
||||||
@ -817,7 +817,7 @@ connection_dir_download_cert_failed(dir_connection_t *conn, int status)
|
|||||||
* 3) Else yes.
|
* 3) Else yes.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
directory_command_should_use_begindir(or_options_t *options,
|
directory_command_should_use_begindir(const or_options_t *options,
|
||||||
const tor_addr_t *addr,
|
const tor_addr_t *addr,
|
||||||
int or_port, uint8_t router_purpose,
|
int or_port, uint8_t router_purpose,
|
||||||
int anonymized_connection)
|
int anonymized_connection)
|
||||||
@ -873,7 +873,7 @@ directory_initiate_command_rend(const char *address, const tor_addr_t *_addr,
|
|||||||
const rend_data_t *rend_query)
|
const rend_data_t *rend_query)
|
||||||
{
|
{
|
||||||
dir_connection_t *conn;
|
dir_connection_t *conn;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
int socket_error = 0;
|
int socket_error = 0;
|
||||||
int use_begindir = supports_begindir &&
|
int use_begindir = supports_begindir &&
|
||||||
directory_command_should_use_begindir(options, _addr,
|
directory_command_should_use_begindir(options, _addr,
|
||||||
@ -2579,7 +2579,7 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
|
|||||||
{
|
{
|
||||||
size_t dlen;
|
size_t dlen;
|
||||||
char *url, *url_mem, *header;
|
char *url, *url_mem, *header;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
time_t if_modified_since = 0;
|
time_t if_modified_since = 0;
|
||||||
int compressed;
|
int compressed;
|
||||||
size_t url_len;
|
size_t url_len;
|
||||||
@ -3295,7 +3295,7 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
|
|||||||
const char *body, size_t body_len)
|
const char *body, size_t body_len)
|
||||||
{
|
{
|
||||||
char *url = NULL;
|
char *url = NULL;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
log_debug(LD_DIRSERV,"Received POST command.");
|
log_debug(LD_DIRSERV,"Received POST command.");
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ dirserv_load_fingerprint_file(void)
|
|||||||
authdir_config_t *fingerprint_list_new;
|
authdir_config_t *fingerprint_list_new;
|
||||||
int result;
|
int result;
|
||||||
config_line_t *front=NULL, *list;
|
config_line_t *front=NULL, *list;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
fname = get_datadir_fname("approved-routers");
|
fname = get_datadir_fname("approved-routers");
|
||||||
log_info(LD_GENERAL,
|
log_info(LD_GENERAL,
|
||||||
@ -1032,7 +1032,7 @@ list_server_status_v1(smartlist_t *routers, char **router_status_out,
|
|||||||
smartlist_t *rs_entries;
|
smartlist_t *rs_entries;
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
time_t cutoff = now - ROUTER_MAX_AGE_TO_PUBLISH;
|
time_t cutoff = now - ROUTER_MAX_AGE_TO_PUBLISH;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
/* We include v2 dir auths here too, because they need to answer
|
/* We include v2 dir auths here too, because they need to answer
|
||||||
* controllers. Eventually we'll deprecate this whole function;
|
* controllers. Eventually we'll deprecate this whole function;
|
||||||
* see also networkstatus_getinfo_by_purpose(). */
|
* see also networkstatus_getinfo_by_purpose(). */
|
||||||
@ -1199,7 +1199,7 @@ dirserv_dump_directory_to_string(char **dir_out,
|
|||||||
/** Return 1 if we fetch our directory material directly from the
|
/** Return 1 if we fetch our directory material directly from the
|
||||||
* authorities, rather than from a mirror. */
|
* authorities, rather than from a mirror. */
|
||||||
int
|
int
|
||||||
directory_fetches_from_authorities(or_options_t *options)
|
directory_fetches_from_authorities(const or_options_t *options)
|
||||||
{
|
{
|
||||||
const routerinfo_t *me;
|
const routerinfo_t *me;
|
||||||
uint32_t addr;
|
uint32_t addr;
|
||||||
@ -1226,7 +1226,7 @@ directory_fetches_from_authorities(or_options_t *options)
|
|||||||
* on the "mirror" schedule rather than the "client" schedule.
|
* on the "mirror" schedule rather than the "client" schedule.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
directory_fetches_dir_info_early(or_options_t *options)
|
directory_fetches_dir_info_early(const or_options_t *options)
|
||||||
{
|
{
|
||||||
return directory_fetches_from_authorities(options);
|
return directory_fetches_from_authorities(options);
|
||||||
}
|
}
|
||||||
@ -1238,7 +1238,7 @@ directory_fetches_dir_info_early(or_options_t *options)
|
|||||||
* client as a directory guard.
|
* client as a directory guard.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
directory_fetches_dir_info_later(or_options_t *options)
|
directory_fetches_dir_info_later(const or_options_t *options)
|
||||||
{
|
{
|
||||||
return options->UseBridges != 0;
|
return options->UseBridges != 0;
|
||||||
}
|
}
|
||||||
@ -1246,7 +1246,7 @@ directory_fetches_dir_info_later(or_options_t *options)
|
|||||||
/** Return 1 if we want to cache v2 dir info (each status file).
|
/** Return 1 if we want to cache v2 dir info (each status file).
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
directory_caches_v2_dir_info(or_options_t *options)
|
directory_caches_v2_dir_info(const or_options_t *options)
|
||||||
{
|
{
|
||||||
return options->DirPort != 0;
|
return options->DirPort != 0;
|
||||||
}
|
}
|
||||||
@ -1255,7 +1255,7 @@ directory_caches_v2_dir_info(or_options_t *options)
|
|||||||
* and we're willing to serve them to others. Else return 0.
|
* and we're willing to serve them to others. Else return 0.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
directory_caches_dir_info(or_options_t *options)
|
directory_caches_dir_info(const or_options_t *options)
|
||||||
{
|
{
|
||||||
if (options->BridgeRelay || options->DirPort)
|
if (options->BridgeRelay || options->DirPort)
|
||||||
return 1;
|
return 1;
|
||||||
@ -1271,7 +1271,7 @@ directory_caches_dir_info(or_options_t *options)
|
|||||||
* requests via the "begin_dir" interface, which doesn't require
|
* requests via the "begin_dir" interface, which doesn't require
|
||||||
* having any separate port open. */
|
* having any separate port open. */
|
||||||
int
|
int
|
||||||
directory_permits_begindir_requests(or_options_t *options)
|
directory_permits_begindir_requests(const or_options_t *options)
|
||||||
{
|
{
|
||||||
return options->BridgeRelay != 0 || options->DirPort != 0;
|
return options->BridgeRelay != 0 || options->DirPort != 0;
|
||||||
}
|
}
|
||||||
@ -1280,7 +1280,7 @@ directory_permits_begindir_requests(or_options_t *options)
|
|||||||
* requests via the controller interface, which doesn't require
|
* requests via the controller interface, which doesn't require
|
||||||
* having any separate port open. */
|
* having any separate port open. */
|
||||||
int
|
int
|
||||||
directory_permits_controller_requests(or_options_t *options)
|
directory_permits_controller_requests(const or_options_t *options)
|
||||||
{
|
{
|
||||||
return options->DirPort != 0;
|
return options->DirPort != 0;
|
||||||
}
|
}
|
||||||
@ -1290,7 +1290,8 @@ directory_permits_controller_requests(or_options_t *options)
|
|||||||
* lately.
|
* lately.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
directory_too_idle_to_fetch_descriptors(or_options_t *options, time_t now)
|
directory_too_idle_to_fetch_descriptors(const or_options_t *options,
|
||||||
|
time_t now)
|
||||||
{
|
{
|
||||||
return !directory_caches_dir_info(options) &&
|
return !directory_caches_dir_info(options) &&
|
||||||
!options->FetchUselessDescriptors &&
|
!options->FetchUselessDescriptors &&
|
||||||
@ -1560,7 +1561,7 @@ dirserv_pick_cached_dir_obj(cached_dir_t *cache_src,
|
|||||||
const char *name,
|
const char *name,
|
||||||
dirinfo_type_t auth_type)
|
dirinfo_type_t auth_type)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
int authority = (auth_type == V1_DIRINFO && authdir_mode_v1(options)) ||
|
int authority = (auth_type == V1_DIRINFO && authdir_mode_v1(options)) ||
|
||||||
(auth_type == V2_DIRINFO && authdir_mode_v2(options));
|
(auth_type == V2_DIRINFO && authdir_mode_v2(options));
|
||||||
|
|
||||||
@ -2251,7 +2252,7 @@ _compare_routerinfo_by_ip_and_bw(const void **a, const void **b)
|
|||||||
static digestmap_t *
|
static digestmap_t *
|
||||||
get_possible_sybil_list(const smartlist_t *routers)
|
get_possible_sybil_list(const smartlist_t *routers)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
digestmap_t *omit_as_sybil;
|
digestmap_t *omit_as_sybil;
|
||||||
smartlist_t *routers_by_ip = smartlist_create();
|
smartlist_t *routers_by_ip = smartlist_create();
|
||||||
uint32_t last_addr;
|
uint32_t last_addr;
|
||||||
@ -2551,7 +2552,7 @@ networkstatus_t *
|
|||||||
dirserv_generate_networkstatus_vote_obj(crypto_pk_env_t *private_key,
|
dirserv_generate_networkstatus_vote_obj(crypto_pk_env_t *private_key,
|
||||||
authority_cert_t *cert)
|
authority_cert_t *cert)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
networkstatus_t *v3_out = NULL;
|
networkstatus_t *v3_out = NULL;
|
||||||
uint32_t addr;
|
uint32_t addr;
|
||||||
char *hostname = NULL, *client_versions = NULL, *server_versions = NULL;
|
char *hostname = NULL, *client_versions = NULL, *server_versions = NULL;
|
||||||
@ -2766,7 +2767,7 @@ generate_v2_networkstatus_opinion(void)
|
|||||||
char *status = NULL, *client_versions = NULL, *server_versions = NULL,
|
char *status = NULL, *client_versions = NULL, *server_versions = NULL,
|
||||||
*identity_pkey = NULL, *hostname = NULL;
|
*identity_pkey = NULL, *hostname = NULL;
|
||||||
char *outp, *endp;
|
char *outp, *endp;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
char fingerprint[FINGERPRINT_LEN+1];
|
char fingerprint[FINGERPRINT_LEN+1];
|
||||||
char published[ISO_TIME_LEN+1];
|
char published[ISO_TIME_LEN+1];
|
||||||
char digest[DIGEST_LEN];
|
char digest[DIGEST_LEN];
|
||||||
|
@ -71,15 +71,16 @@ int list_server_status_v1(smartlist_t *routers, char **router_status_out,
|
|||||||
int dirserv_dump_directory_to_string(char **dir_out,
|
int dirserv_dump_directory_to_string(char **dir_out,
|
||||||
crypto_pk_env_t *private_key);
|
crypto_pk_env_t *private_key);
|
||||||
|
|
||||||
int directory_fetches_from_authorities(or_options_t *options);
|
int directory_fetches_from_authorities(const or_options_t *options);
|
||||||
int directory_fetches_dir_info_early(or_options_t *options);
|
int directory_fetches_dir_info_early(const or_options_t *options);
|
||||||
int directory_fetches_dir_info_later(or_options_t *options);
|
int directory_fetches_dir_info_later(const or_options_t *options);
|
||||||
int directory_caches_v2_dir_info(or_options_t *options);
|
int directory_caches_v2_dir_info(const or_options_t *options);
|
||||||
#define directory_caches_v1_dir_info(o) directory_caches_v2_dir_info(o)
|
#define directory_caches_v1_dir_info(o) directory_caches_v2_dir_info(o)
|
||||||
int directory_caches_dir_info(or_options_t *options);
|
int directory_caches_dir_info(const or_options_t *options);
|
||||||
int directory_permits_begindir_requests(or_options_t *options);
|
int directory_permits_begindir_requests(const or_options_t *options);
|
||||||
int directory_permits_controller_requests(or_options_t *options);
|
int directory_permits_controller_requests(const or_options_t *options);
|
||||||
int directory_too_idle_to_fetch_descriptors(or_options_t *options, time_t now);
|
int directory_too_idle_to_fetch_descriptors(const or_options_t *options,
|
||||||
|
time_t now);
|
||||||
|
|
||||||
void directory_set_dirty(void);
|
void directory_set_dirty(void);
|
||||||
cached_dir_t *dirserv_get_directory(void);
|
cached_dir_t *dirserv_get_directory(void);
|
||||||
|
@ -2504,7 +2504,7 @@ authority_cert_dup(authority_cert_t *cert)
|
|||||||
void
|
void
|
||||||
dirvote_get_preferred_voting_intervals(vote_timing_t *timing_out)
|
dirvote_get_preferred_voting_intervals(vote_timing_t *timing_out)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
tor_assert(timing_out);
|
tor_assert(timing_out);
|
||||||
|
|
||||||
@ -2578,7 +2578,7 @@ static struct {
|
|||||||
/** Set voting_schedule to hold the timing for the next vote we should be
|
/** Set voting_schedule to hold the timing for the next vote we should be
|
||||||
* doing. */
|
* doing. */
|
||||||
void
|
void
|
||||||
dirvote_recalculate_timing(or_options_t *options, time_t now)
|
dirvote_recalculate_timing(const or_options_t *options, time_t now)
|
||||||
{
|
{
|
||||||
int interval, vote_delay, dist_delay;
|
int interval, vote_delay, dist_delay;
|
||||||
time_t start;
|
time_t start;
|
||||||
@ -2629,7 +2629,7 @@ dirvote_recalculate_timing(or_options_t *options, time_t now)
|
|||||||
|
|
||||||
/** Entry point: Take whatever voting actions are pending as of <b>now</b>. */
|
/** Entry point: Take whatever voting actions are pending as of <b>now</b>. */
|
||||||
void
|
void
|
||||||
dirvote_act(or_options_t *options, time_t now)
|
dirvote_act(const or_options_t *options, time_t now)
|
||||||
{
|
{
|
||||||
if (!authdir_mode_v3(options))
|
if (!authdir_mode_v3(options))
|
||||||
return;
|
return;
|
||||||
|
@ -41,8 +41,8 @@ authority_cert_t *authority_cert_dup(authority_cert_t *cert);
|
|||||||
/* vote scheduling */
|
/* vote scheduling */
|
||||||
void dirvote_get_preferred_voting_intervals(vote_timing_t *timing_out);
|
void dirvote_get_preferred_voting_intervals(vote_timing_t *timing_out);
|
||||||
time_t dirvote_get_start_of_next_interval(time_t now, int interval);
|
time_t dirvote_get_start_of_next_interval(time_t now, int interval);
|
||||||
void dirvote_recalculate_timing(or_options_t *options, time_t now);
|
void dirvote_recalculate_timing(const or_options_t *options, time_t now);
|
||||||
void dirvote_act(or_options_t *options, time_t now);
|
void dirvote_act(const or_options_t *options, time_t now);
|
||||||
|
|
||||||
/* invoked on timers and by outside triggers. */
|
/* invoked on timers and by outside triggers. */
|
||||||
struct pending_vote_t * dirvote_add_vote(const char *vote_body,
|
struct pending_vote_t * dirvote_add_vote(const char *vote_body,
|
||||||
|
@ -276,7 +276,7 @@ dns_init(void)
|
|||||||
int
|
int
|
||||||
dns_reset(void)
|
dns_reset(void)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
if (! server_mode(options)) {
|
if (! server_mode(options)) {
|
||||||
|
|
||||||
if (!the_evdns_base) {
|
if (!the_evdns_base) {
|
||||||
@ -1026,7 +1026,7 @@ add_answer_to_cache(const char *address, uint8_t is_reverse, uint32_t addr,
|
|||||||
static INLINE int
|
static INLINE int
|
||||||
is_test_address(const char *address)
|
is_test_address(const char *address)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
return options->ServerDNSTestAddresses &&
|
return options->ServerDNSTestAddresses &&
|
||||||
smartlist_string_isin_case(options->ServerDNSTestAddresses, address);
|
smartlist_string_isin_case(options->ServerDNSTestAddresses, address);
|
||||||
}
|
}
|
||||||
@ -1177,7 +1177,7 @@ evdns_err_is_transient(int err)
|
|||||||
static int
|
static int
|
||||||
configure_nameservers(int force)
|
configure_nameservers(int force)
|
||||||
{
|
{
|
||||||
or_options_t *options;
|
const or_options_t *options;
|
||||||
const char *conf_fname;
|
const char *conf_fname;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int r;
|
int r;
|
||||||
@ -1595,7 +1595,7 @@ launch_wildcard_check(int min_len, int max_len, const char *suffix)
|
|||||||
static void
|
static void
|
||||||
launch_test_addresses(int fd, short event, void *args)
|
launch_test_addresses(int fd, short event, void *args)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
struct evdns_request *req;
|
struct evdns_request *req;
|
||||||
(void)fd;
|
(void)fd;
|
||||||
(void)event;
|
(void)event;
|
||||||
|
@ -162,7 +162,7 @@ _geoip_compare_key_to_entry(const void *_key, const void **_member)
|
|||||||
/** Return 1 if we should collect geoip stats on bridge users, and
|
/** Return 1 if we should collect geoip stats on bridge users, and
|
||||||
* include them in our extrainfo descriptor. Else return 0. */
|
* include them in our extrainfo descriptor. Else return 0. */
|
||||||
int
|
int
|
||||||
should_record_bridge_info(or_options_t *options)
|
should_record_bridge_info(const or_options_t *options)
|
||||||
{
|
{
|
||||||
return options->BridgeRelay && options->BridgeRecordUsageByCountry;
|
return options->BridgeRelay && options->BridgeRecordUsageByCountry;
|
||||||
}
|
}
|
||||||
@ -199,7 +199,7 @@ init_geoip_countries(void)
|
|||||||
* with '#' (comments).
|
* with '#' (comments).
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
geoip_load_file(const char *filename, or_options_t *options)
|
geoip_load_file(const char *filename, const or_options_t *options)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
const char *msg = "";
|
const char *msg = "";
|
||||||
@ -424,7 +424,7 @@ void
|
|||||||
geoip_note_client_seen(geoip_client_action_t action,
|
geoip_note_client_seen(geoip_client_action_t action,
|
||||||
uint32_t addr, time_t now)
|
uint32_t addr, time_t now)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
clientmap_entry_t lookup, *ent;
|
clientmap_entry_t lookup, *ent;
|
||||||
if (action == GEOIP_CLIENT_CONNECT) {
|
if (action == GEOIP_CLIENT_CONNECT) {
|
||||||
/* Only remember statistics as entry guard or as bridge. */
|
/* Only remember statistics as entry guard or as bridge. */
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
#ifdef GEOIP_PRIVATE
|
#ifdef GEOIP_PRIVATE
|
||||||
int geoip_parse_entry(const char *line);
|
int geoip_parse_entry(const char *line);
|
||||||
#endif
|
#endif
|
||||||
int should_record_bridge_info(or_options_t *options);
|
int should_record_bridge_info(const or_options_t *options);
|
||||||
int geoip_load_file(const char *filename, or_options_t *options);
|
int geoip_load_file(const char *filename, const or_options_t *options);
|
||||||
int geoip_get_country_by_ip(uint32_t ipaddr);
|
int geoip_get_country_by_ip(uint32_t ipaddr);
|
||||||
int geoip_get_n_countries(void);
|
int geoip_get_n_countries(void);
|
||||||
const char *geoip_get_country_name(country_t num);
|
const char *geoip_get_country_name(country_t num);
|
||||||
|
@ -134,7 +134,7 @@ static void accounting_set_wakeup_time(void);
|
|||||||
* options->AccountingStart. Return 0 on success, -1 on failure. If
|
* options->AccountingStart. Return 0 on success, -1 on failure. If
|
||||||
* <b>validate_only</b> is true, do not change the current settings. */
|
* <b>validate_only</b> is true, do not change the current settings. */
|
||||||
int
|
int
|
||||||
accounting_parse_options(or_options_t *options, int validate_only)
|
accounting_parse_options(const or_options_t *options, int validate_only)
|
||||||
{
|
{
|
||||||
time_unit_t unit;
|
time_unit_t unit;
|
||||||
int ok, idx;
|
int ok, idx;
|
||||||
@ -249,7 +249,7 @@ accounting_parse_options(or_options_t *options, int validate_only)
|
|||||||
* hibernate, return 1, else return 0.
|
* hibernate, return 1, else return 0.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
accounting_is_enabled(or_options_t *options)
|
accounting_is_enabled(const or_options_t *options)
|
||||||
{
|
{
|
||||||
if (options->AccountingMax)
|
if (options->AccountingMax)
|
||||||
return 1;
|
return 1;
|
||||||
@ -411,7 +411,7 @@ static void
|
|||||||
update_expected_bandwidth(void)
|
update_expected_bandwidth(void)
|
||||||
{
|
{
|
||||||
uint64_t expected;
|
uint64_t expected;
|
||||||
or_options_t *options= get_options();
|
const or_options_t *options= get_options();
|
||||||
uint64_t max_configured = (options->RelayBandwidthRate > 0 ?
|
uint64_t max_configured = (options->RelayBandwidthRate > 0 ?
|
||||||
options->RelayBandwidthRate :
|
options->RelayBandwidthRate :
|
||||||
options->BandwidthRate) * 60;
|
options->BandwidthRate) * 60;
|
||||||
@ -750,7 +750,7 @@ static void
|
|||||||
hibernate_begin(hibernate_state_t new_state, time_t now)
|
hibernate_begin(hibernate_state_t new_state, time_t now)
|
||||||
{
|
{
|
||||||
connection_t *conn;
|
connection_t *conn;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
if (new_state == HIBERNATE_STATE_EXITING &&
|
if (new_state == HIBERNATE_STATE_EXITING &&
|
||||||
hibernate_state != HIBERNATE_STATE_LIVE) {
|
hibernate_state != HIBERNATE_STATE_LIVE) {
|
||||||
|
@ -12,8 +12,8 @@
|
|||||||
#ifndef _TOR_HIBERNATE_H
|
#ifndef _TOR_HIBERNATE_H
|
||||||
#define _TOR_HIBERNATE_H
|
#define _TOR_HIBERNATE_H
|
||||||
|
|
||||||
int accounting_parse_options(or_options_t *options, int validate_only);
|
int accounting_parse_options(const or_options_t *options, int validate_only);
|
||||||
int accounting_is_enabled(or_options_t *options);
|
int accounting_is_enabled(const or_options_t *options);
|
||||||
void configure_accounting(time_t now);
|
void configure_accounting(time_t now);
|
||||||
void accounting_run_housekeeping(time_t now);
|
void accounting_run_housekeeping(time_t now);
|
||||||
void accounting_add_bytes(size_t n_read, size_t n_written, int seconds);
|
void accounting_add_bytes(size_t n_read, size_t n_written, int seconds);
|
||||||
|
@ -867,7 +867,7 @@ directory_all_unreachable(time_t now)
|
|||||||
void
|
void
|
||||||
directory_info_has_arrived(time_t now, int from_cache)
|
directory_info_has_arrived(time_t now, int from_cache)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
if (!router_have_minimum_dir_info()) {
|
if (!router_have_minimum_dir_info()) {
|
||||||
int quiet = directory_too_idle_to_fetch_descriptors(options, now);
|
int quiet = directory_too_idle_to_fetch_descriptors(options, now);
|
||||||
@ -912,7 +912,7 @@ run_connection_housekeeping(int i, time_t now)
|
|||||||
{
|
{
|
||||||
cell_t cell;
|
cell_t cell;
|
||||||
connection_t *conn = smartlist_get(connection_array, i);
|
connection_t *conn = smartlist_get(connection_array, i);
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
or_connection_t *or_conn;
|
or_connection_t *or_conn;
|
||||||
int past_keepalive =
|
int past_keepalive =
|
||||||
now >= conn->timestamp_lastwritten + options->KeepalivePeriod;
|
now >= conn->timestamp_lastwritten + options->KeepalivePeriod;
|
||||||
@ -1018,7 +1018,7 @@ run_connection_housekeeping(int i, time_t now)
|
|||||||
static void
|
static void
|
||||||
signewnym_impl(time_t now)
|
signewnym_impl(time_t now)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
if (!proxy_mode(options)) {
|
if (!proxy_mode(options)) {
|
||||||
log_info(LD_CONTROL, "Ignoring SIGNAL NEWNYM because client functionality "
|
log_info(LD_CONTROL, "Ignoring SIGNAL NEWNYM because client functionality "
|
||||||
"is disabled.");
|
"is disabled.");
|
||||||
@ -1060,7 +1060,7 @@ run_scheduled_events(time_t now)
|
|||||||
static int should_init_bridge_stats = 1;
|
static int should_init_bridge_stats = 1;
|
||||||
static time_t time_to_retry_dns_init = 0;
|
static time_t time_to_retry_dns_init = 0;
|
||||||
static time_t time_to_next_heartbeat = 0;
|
static time_t time_to_next_heartbeat = 0;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
int is_server = server_mode(options);
|
int is_server = server_mode(options);
|
||||||
int i;
|
int i;
|
||||||
int have_dir_info;
|
int have_dir_info;
|
||||||
@ -1487,7 +1487,7 @@ second_elapsed_callback(periodic_timer_t *timer, void *arg)
|
|||||||
#ifdef USE_BUFFEREVENTS
|
#ifdef USE_BUFFEREVENTS
|
||||||
uint64_t cur_read,cur_written;
|
uint64_t cur_read,cur_written;
|
||||||
#endif
|
#endif
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
(void)timer;
|
(void)timer;
|
||||||
(void)arg;
|
(void)arg;
|
||||||
|
|
||||||
@ -1630,7 +1630,7 @@ dns_servers_relaunch_checks(void)
|
|||||||
static int
|
static int
|
||||||
do_hup(void)
|
do_hup(void)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
#ifdef USE_DMALLOC
|
#ifdef USE_DMALLOC
|
||||||
dmalloc_log_stats();
|
dmalloc_log_stats();
|
||||||
@ -2172,7 +2172,7 @@ static tor_lockfile_t *lockfile = NULL;
|
|||||||
* return -1 if we can't get the lockfile. Return 0 on success.
|
* return -1 if we can't get the lockfile. Return 0 on success.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
try_locking(or_options_t *options, int err_if_locked)
|
try_locking(const or_options_t *options, int err_if_locked)
|
||||||
{
|
{
|
||||||
if (lockfile)
|
if (lockfile)
|
||||||
return 0;
|
return 0;
|
||||||
@ -2286,7 +2286,7 @@ tor_free_all(int postfork)
|
|||||||
void
|
void
|
||||||
tor_cleanup(void)
|
tor_cleanup(void)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
if (options->command == CMD_RUN_TOR) {
|
if (options->command == CMD_RUN_TOR) {
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
/* Remove our pid file. We don't care if there was an error when we
|
/* Remove our pid file. We don't care if there was an error when we
|
||||||
|
@ -56,7 +56,7 @@ long get_uptime(void);
|
|||||||
void handle_signals(int is_parent);
|
void handle_signals(int is_parent);
|
||||||
void process_signal(uintptr_t sig);
|
void process_signal(uintptr_t sig);
|
||||||
|
|
||||||
int try_locking(or_options_t *options, int err_if_locked);
|
int try_locking(const or_options_t *options, int err_if_locked);
|
||||||
int have_lockfile(void);
|
int have_lockfile(void);
|
||||||
void release_lockfile(void);
|
void release_lockfile(void);
|
||||||
|
|
||||||
|
@ -595,7 +595,7 @@ microdesc_list_missing_digest256(networkstatus_t *ns, microdesc_cache_t *cache,
|
|||||||
void
|
void
|
||||||
update_microdesc_downloads(time_t now)
|
update_microdesc_downloads(time_t now)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
networkstatus_t *consensus;
|
networkstatus_t *consensus;
|
||||||
smartlist_t *missing;
|
smartlist_t *missing;
|
||||||
digestmap_t *pending;
|
digestmap_t *pending;
|
||||||
@ -654,7 +654,7 @@ update_microdescs_from_networkstatus(time_t now)
|
|||||||
/** Return true iff we should prefer to use microdescriptors rather than
|
/** Return true iff we should prefer to use microdescriptors rather than
|
||||||
* routerdescs for building circuits. */
|
* routerdescs for building circuits. */
|
||||||
int
|
int
|
||||||
we_use_microdescriptors_for_circuits(or_options_t *options)
|
we_use_microdescriptors_for_circuits(const or_options_t *options)
|
||||||
{
|
{
|
||||||
int ret = options->UseMicrodescriptors;
|
int ret = options->UseMicrodescriptors;
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
@ -673,7 +673,7 @@ we_use_microdescriptors_for_circuits(or_options_t *options)
|
|||||||
|
|
||||||
/** Return true iff we should try to download microdescriptors at all. */
|
/** Return true iff we should try to download microdescriptors at all. */
|
||||||
int
|
int
|
||||||
we_fetch_microdescriptors(or_options_t *options)
|
we_fetch_microdescriptors(const or_options_t *options)
|
||||||
{
|
{
|
||||||
if (directory_caches_dir_info(options))
|
if (directory_caches_dir_info(options))
|
||||||
return 1;
|
return 1;
|
||||||
@ -682,7 +682,7 @@ we_fetch_microdescriptors(or_options_t *options)
|
|||||||
|
|
||||||
/** Return true iff we should try to download router descriptors at all. */
|
/** Return true iff we should try to download router descriptors at all. */
|
||||||
int
|
int
|
||||||
we_fetch_router_descriptors(or_options_t *options)
|
we_fetch_router_descriptors(const or_options_t *options)
|
||||||
{
|
{
|
||||||
if (directory_caches_dir_info(options))
|
if (directory_caches_dir_info(options))
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -44,9 +44,9 @@ void update_microdesc_downloads(time_t now);
|
|||||||
void update_microdescs_from_networkstatus(time_t now);
|
void update_microdescs_from_networkstatus(time_t now);
|
||||||
|
|
||||||
int usable_consensus_flavor(void);
|
int usable_consensus_flavor(void);
|
||||||
int we_fetch_microdescriptors(or_options_t *options);
|
int we_fetch_microdescriptors(const or_options_t *options);
|
||||||
int we_fetch_router_descriptors(or_options_t *options);
|
int we_fetch_router_descriptors(const or_options_t *options);
|
||||||
int we_use_microdescriptors_for_circuits(or_options_t *options);
|
int we_use_microdescriptors_for_circuits(const or_options_t *options);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ router_reload_consensus_networkstatus(void)
|
|||||||
char *filename;
|
char *filename;
|
||||||
char *s;
|
char *s;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
const unsigned int flags = NSSET_FROM_CACHE | NSSET_DONT_DOWNLOAD_CERTS;
|
const unsigned int flags = NSSET_FROM_CACHE | NSSET_DONT_DOWNLOAD_CERTS;
|
||||||
int flav;
|
int flav;
|
||||||
|
|
||||||
@ -1175,7 +1175,7 @@ update_v2_networkstatus_cache_downloads(time_t now)
|
|||||||
|
|
||||||
/** DOCDOC */
|
/** DOCDOC */
|
||||||
static int
|
static int
|
||||||
we_want_to_fetch_flavor(or_options_t *options, int flavor)
|
we_want_to_fetch_flavor(const or_options_t *options, int flavor)
|
||||||
{
|
{
|
||||||
if (flavor < 0 || flavor > N_CONSENSUS_FLAVORS) {
|
if (flavor < 0 || flavor > N_CONSENSUS_FLAVORS) {
|
||||||
/* This flavor is crazy; we don't want it */
|
/* This flavor is crazy; we don't want it */
|
||||||
@ -1204,7 +1204,7 @@ static void
|
|||||||
update_consensus_networkstatus_downloads(time_t now)
|
update_consensus_networkstatus_downloads(time_t now)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
if (!networkstatus_get_live_consensus(now))
|
if (!networkstatus_get_live_consensus(now))
|
||||||
time_to_download_next_consensus = now; /* No live consensus? Get one now!*/
|
time_to_download_next_consensus = now; /* No live consensus? Get one now!*/
|
||||||
@ -1274,7 +1274,7 @@ networkstatus_consensus_download_failed(int status_code, const char *flavname)
|
|||||||
void
|
void
|
||||||
update_consensus_networkstatus_fetch_time(time_t now)
|
update_consensus_networkstatus_fetch_time(time_t now)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
networkstatus_t *c = networkstatus_get_live_consensus(now);
|
networkstatus_t *c = networkstatus_get_live_consensus(now);
|
||||||
if (c) {
|
if (c) {
|
||||||
long dl_interval;
|
long dl_interval;
|
||||||
@ -1348,7 +1348,7 @@ update_consensus_networkstatus_fetch_time(time_t now)
|
|||||||
* fetches yet (e.g. we demand bridges and none are yet known).
|
* fetches yet (e.g. we demand bridges and none are yet known).
|
||||||
* Else return 0. */
|
* Else return 0. */
|
||||||
int
|
int
|
||||||
should_delay_dir_fetches(or_options_t *options)
|
should_delay_dir_fetches(const or_options_t *options)
|
||||||
{
|
{
|
||||||
if (options->UseBridges && !any_bridge_descriptors_known()) {
|
if (options->UseBridges && !any_bridge_descriptors_known()) {
|
||||||
log_info(LD_DIR, "delaying dir fetches (no running bridges known)");
|
log_info(LD_DIR, "delaying dir fetches (no running bridges known)");
|
||||||
@ -1362,7 +1362,7 @@ should_delay_dir_fetches(or_options_t *options)
|
|||||||
void
|
void
|
||||||
update_networkstatus_downloads(time_t now)
|
update_networkstatus_downloads(time_t now)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
if (should_delay_dir_fetches(options))
|
if (should_delay_dir_fetches(options))
|
||||||
return;
|
return;
|
||||||
if (authdir_mode_any_main(options) || options->FetchV2Networkstatus)
|
if (authdir_mode_any_main(options) || options->FetchV2Networkstatus)
|
||||||
@ -1585,7 +1585,7 @@ networkstatus_set_current_consensus(const char *consensus,
|
|||||||
networkstatus_t *c=NULL;
|
networkstatus_t *c=NULL;
|
||||||
int r, result = -1;
|
int r, result = -1;
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
char *unverified_fname = NULL, *consensus_fname = NULL;
|
char *unverified_fname = NULL, *consensus_fname = NULL;
|
||||||
int flav = networkstatus_parse_flavor_name(flavor);
|
int flav = networkstatus_parse_flavor_name(flavor);
|
||||||
const unsigned from_cache = flags & NSSET_FROM_CACHE;
|
const unsigned from_cache = flags & NSSET_FROM_CACHE;
|
||||||
@ -1991,7 +1991,7 @@ routers_update_status_from_consensus_networkstatus(smartlist_t *routers,
|
|||||||
int reset_failures)
|
int reset_failures)
|
||||||
{
|
{
|
||||||
trusted_dir_server_t *ds;
|
trusted_dir_server_t *ds;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
int authdir = authdir_mode_v2(options) || authdir_mode_v3(options);
|
int authdir = authdir_mode_v2(options) || authdir_mode_v3(options);
|
||||||
networkstatus_t *ns = current_consensus;
|
networkstatus_t *ns = current_consensus;
|
||||||
if (!ns || !smartlist_len(ns->routerstatus_list))
|
if (!ns || !smartlist_len(ns->routerstatus_list))
|
||||||
@ -2151,7 +2151,7 @@ void
|
|||||||
networkstatus_dump_bridge_status_to_file(time_t now)
|
networkstatus_dump_bridge_status_to_file(time_t now)
|
||||||
{
|
{
|
||||||
char *status = networkstatus_getinfo_by_purpose("bridge", now);
|
char *status = networkstatus_getinfo_by_purpose("bridge", now);
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
size_t len = strlen(options->DataDirectory) + 32;
|
size_t len = strlen(options->DataDirectory) + 32;
|
||||||
char *fname = tor_malloc(len);
|
char *fname = tor_malloc(len);
|
||||||
tor_snprintf(fname, len, "%s"PATH_SEPARATOR"networkstatus-bridges",
|
tor_snprintf(fname, len, "%s"PATH_SEPARATOR"networkstatus-bridges",
|
||||||
@ -2205,7 +2205,7 @@ get_net_param_from_list(smartlist_t *net_params, const char *param_name,
|
|||||||
* <b>min_val</b> and at most <b>max_val</b> and raise/cap the parsed value
|
* <b>min_val</b> and at most <b>max_val</b> and raise/cap the parsed value
|
||||||
* if necessary. */
|
* if necessary. */
|
||||||
int32_t
|
int32_t
|
||||||
networkstatus_get_param(networkstatus_t *ns, const char *param_name,
|
networkstatus_get_param(const networkstatus_t *ns, const char *param_name,
|
||||||
int32_t default_val, int32_t min_val, int32_t max_val)
|
int32_t default_val, int32_t min_val, int32_t max_val)
|
||||||
{
|
{
|
||||||
if (!ns) /* if they pass in null, go find it ourselves */
|
if (!ns) /* if they pass in null, go find it ourselves */
|
||||||
|
@ -67,7 +67,7 @@ int networkstatus_nickname_is_unnamed(const char *nickname);
|
|||||||
void networkstatus_consensus_download_failed(int status_code,
|
void networkstatus_consensus_download_failed(int status_code,
|
||||||
const char *flavname);
|
const char *flavname);
|
||||||
void update_consensus_networkstatus_fetch_time(time_t now);
|
void update_consensus_networkstatus_fetch_time(time_t now);
|
||||||
int should_delay_dir_fetches(or_options_t *options);
|
int should_delay_dir_fetches(const or_options_t *options);
|
||||||
void update_networkstatus_downloads(time_t now);
|
void update_networkstatus_downloads(time_t now);
|
||||||
void update_certificate_downloads(time_t now);
|
void update_certificate_downloads(time_t now);
|
||||||
int consensus_is_waiting_for_certs(void);
|
int consensus_is_waiting_for_certs(void);
|
||||||
@ -96,7 +96,8 @@ void signed_descs_update_status_from_consensus_networkstatus(
|
|||||||
char *networkstatus_getinfo_helper_single(const routerstatus_t *rs);
|
char *networkstatus_getinfo_helper_single(const routerstatus_t *rs);
|
||||||
char *networkstatus_getinfo_by_purpose(const char *purpose_string, time_t now);
|
char *networkstatus_getinfo_by_purpose(const char *purpose_string, time_t now);
|
||||||
void networkstatus_dump_bridge_status_to_file(time_t now);
|
void networkstatus_dump_bridge_status_to_file(time_t now);
|
||||||
int32_t networkstatus_get_param(networkstatus_t *ns, const char *param_name,
|
int32_t networkstatus_get_param(const networkstatus_t *ns,
|
||||||
|
const char *param_name,
|
||||||
int32_t default_val, int32_t min_val,
|
int32_t default_val, int32_t min_val,
|
||||||
int32_t max_val);
|
int32_t max_val);
|
||||||
int getinfo_helper_networkstatus(control_connection_t *conn,
|
int getinfo_helper_networkstatus(control_connection_t *conn,
|
||||||
|
@ -171,7 +171,7 @@ nodelist_add_microdesc(microdesc_t *md)
|
|||||||
void
|
void
|
||||||
nodelist_set_consensus(networkstatus_t *ns)
|
nodelist_set_consensus(networkstatus_t *ns)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
int authdir = authdir_mode_v2(options) || authdir_mode_v3(options);
|
int authdir = authdir_mode_v2(options) || authdir_mode_v3(options);
|
||||||
init_nodelist();
|
init_nodelist();
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ parse_addr_policy(config_line_t *cfg, smartlist_t **dest,
|
|||||||
static int
|
static int
|
||||||
parse_reachable_addresses(void)
|
parse_reachable_addresses(void)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (options->ReachableDirAddresses &&
|
if (options->ReachableDirAddresses &&
|
||||||
@ -356,7 +356,7 @@ authdir_policy_badexit_address(uint32_t addr, uint16_t port)
|
|||||||
* options in <b>options</b>, return -1 and set <b>msg</b> to a newly
|
* options in <b>options</b>, return -1 and set <b>msg</b> to a newly
|
||||||
* allocated description of the error. Else return 0. */
|
* allocated description of the error. Else return 0. */
|
||||||
int
|
int
|
||||||
validate_addr_policies(or_options_t *options, char **msg)
|
validate_addr_policies(const or_options_t *options, char **msg)
|
||||||
{
|
{
|
||||||
/* XXXX Maybe merge this into parse_policies_from_options, to make sure
|
/* XXXX Maybe merge this into parse_policies_from_options, to make sure
|
||||||
* that the two can't go out of sync. */
|
* that the two can't go out of sync. */
|
||||||
@ -440,7 +440,7 @@ load_policy_from_option(config_line_t *config, smartlist_t **policy,
|
|||||||
/** Set all policies based on <b>options</b>, which should have been validated
|
/** Set all policies based on <b>options</b>, which should have been validated
|
||||||
* first by validate_addr_policies. */
|
* first by validate_addr_policies. */
|
||||||
int
|
int
|
||||||
policies_parse_from_options(or_options_t *options)
|
policies_parse_from_options(const or_options_t *options)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
if (load_policy_from_option(options->SocksPolicy, &socks_policy, -1) < 0)
|
if (load_policy_from_option(options->SocksPolicy, &socks_policy, -1) < 0)
|
||||||
|
@ -29,9 +29,9 @@ int authdir_policy_valid_address(uint32_t addr, uint16_t port);
|
|||||||
int authdir_policy_baddir_address(uint32_t addr, uint16_t port);
|
int authdir_policy_baddir_address(uint32_t addr, uint16_t port);
|
||||||
int authdir_policy_badexit_address(uint32_t addr, uint16_t port);
|
int authdir_policy_badexit_address(uint32_t addr, uint16_t port);
|
||||||
|
|
||||||
int validate_addr_policies(or_options_t *options, char **msg);
|
int validate_addr_policies(const or_options_t *options, char **msg);
|
||||||
void policy_expand_private(smartlist_t **policy);
|
void policy_expand_private(smartlist_t **policy);
|
||||||
int policies_parse_from_options(or_options_t *options);
|
int policies_parse_from_options(const or_options_t *options);
|
||||||
|
|
||||||
addr_policy_t *addr_policy_get_canonical_entry(addr_policy_t *ent);
|
addr_policy_t *addr_policy_get_canonical_entry(addr_policy_t *ent);
|
||||||
int cmp_addr_policies(smartlist_t *a, smartlist_t *b);
|
int cmp_addr_policies(smartlist_t *a, smartlist_t *b);
|
||||||
|
@ -2010,7 +2010,8 @@ static int ewma_enabled = 0;
|
|||||||
|
|
||||||
/** Adjust the global cell scale factor based on <b>options</b> */
|
/** Adjust the global cell scale factor based on <b>options</b> */
|
||||||
void
|
void
|
||||||
cell_ewma_set_scale_factor(or_options_t *options, networkstatus_t *consensus)
|
cell_ewma_set_scale_factor(const or_options_t *options,
|
||||||
|
const networkstatus_t *consensus)
|
||||||
{
|
{
|
||||||
int32_t halflife_ms;
|
int32_t halflife_ms;
|
||||||
double halflife;
|
double halflife;
|
||||||
|
@ -60,8 +60,8 @@ const uint8_t *decode_address_from_payload(tor_addr_t *addr_out,
|
|||||||
const uint8_t *payload,
|
const uint8_t *payload,
|
||||||
int payload_len);
|
int payload_len);
|
||||||
unsigned cell_ewma_get_tick(void);
|
unsigned cell_ewma_get_tick(void);
|
||||||
void cell_ewma_set_scale_factor(or_options_t *options,
|
void cell_ewma_set_scale_factor(const or_options_t *options,
|
||||||
networkstatus_t *consensus);
|
const networkstatus_t *consensus);
|
||||||
void circuit_clear_cell_queue(circuit_t *circ, or_connection_t *orconn);
|
void circuit_clear_cell_queue(circuit_t *circ, or_connection_t *orconn);
|
||||||
|
|
||||||
void tor_gettimeofday_cache_clear(void);
|
void tor_gettimeofday_cache_clear(void);
|
||||||
|
@ -903,7 +903,7 @@ rend_client_get_random_intro_impl(const rend_cache_entry_t *entry,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
rend_intro_point_t *intro;
|
rend_intro_point_t *intro;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
smartlist_t *usable_nodes;
|
smartlist_t *usable_nodes;
|
||||||
int n_excluded = 0;
|
int n_excluded = 0;
|
||||||
|
|
||||||
@ -1010,7 +1010,8 @@ rend_service_authorization_free_all(void)
|
|||||||
* service and add it to the local map of hidden service authorizations.
|
* service and add it to the local map of hidden service authorizations.
|
||||||
* Return 0 for success and -1 for failure. */
|
* Return 0 for success and -1 for failure. */
|
||||||
int
|
int
|
||||||
rend_parse_service_authorization(or_options_t *options, int validate_only)
|
rend_parse_service_authorization(const or_options_t *options,
|
||||||
|
int validate_only)
|
||||||
{
|
{
|
||||||
config_line_t *line;
|
config_line_t *line;
|
||||||
int res = -1;
|
int res = -1;
|
||||||
|
@ -37,7 +37,7 @@ int rend_client_any_intro_points_usable(const rend_cache_entry_t *entry);
|
|||||||
|
|
||||||
int rend_client_send_introduction(origin_circuit_t *introcirc,
|
int rend_client_send_introduction(origin_circuit_t *introcirc,
|
||||||
origin_circuit_t *rendcirc);
|
origin_circuit_t *rendcirc);
|
||||||
int rend_parse_service_authorization(or_options_t *options,
|
int rend_parse_service_authorization(const or_options_t *options,
|
||||||
int validate_only);
|
int validate_only);
|
||||||
rend_service_authorization_t *rend_client_lookup_service_authorization(
|
rend_service_authorization_t *rend_client_lookup_service_authorization(
|
||||||
const char *onion_address);
|
const char *onion_address);
|
||||||
|
@ -292,7 +292,7 @@ parse_port_config(const char *string)
|
|||||||
* normal, but don't actually change the configured services.)
|
* normal, but don't actually change the configured services.)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
rend_config_services(or_options_t *options, int validate_only)
|
rend_config_services(const or_options_t *options, int validate_only)
|
||||||
{
|
{
|
||||||
config_line_t *line;
|
config_line_t *line;
|
||||||
rend_service_t *service = NULL;
|
rend_service_t *service = NULL;
|
||||||
@ -903,7 +903,7 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
|
|||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
char diffie_hellman_hash[DIGEST_LEN];
|
char diffie_hellman_hash[DIGEST_LEN];
|
||||||
time_t *access_time;
|
time_t *access_time;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
tor_assert(circuit->rend_data);
|
tor_assert(circuit->rend_data);
|
||||||
|
|
||||||
@ -1377,7 +1377,7 @@ rend_service_intro_has_opened(origin_circuit_t *circuit)
|
|||||||
/* If we already have enough introduction circuits for this service,
|
/* If we already have enough introduction circuits for this service,
|
||||||
* redefine this one as a general circuit or close it, depending. */
|
* redefine this one as a general circuit or close it, depending. */
|
||||||
if (count_established_intro_points(serviceid) > NUM_INTRO_POINTS) {
|
if (count_established_intro_points(serviceid) > NUM_INTRO_POINTS) {
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
if (options->ExcludeNodes) {
|
if (options->ExcludeNodes) {
|
||||||
/* XXXX in some future version, we can test whether the transition is
|
/* XXXX in some future version, we can test whether the transition is
|
||||||
allowed or not given the actual nodes in the circuit. But for now,
|
allowed or not given the actual nodes in the circuit. But for now,
|
||||||
@ -1817,7 +1817,7 @@ rend_services_introduce(void)
|
|||||||
int changed, prev_intro_nodes;
|
int changed, prev_intro_nodes;
|
||||||
smartlist_t *intro_nodes;
|
smartlist_t *intro_nodes;
|
||||||
time_t now;
|
time_t now;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
intro_nodes = smartlist_create();
|
intro_nodes = smartlist_create();
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#define _TOR_RENDSERVICE_H
|
#define _TOR_RENDSERVICE_H
|
||||||
|
|
||||||
int num_rend_services(void);
|
int num_rend_services(void);
|
||||||
int rend_config_services(or_options_t *options, int validate_only);
|
int rend_config_services(const or_options_t *options, int validate_only);
|
||||||
int rend_service_load_keys(void);
|
int rend_service_load_keys(void);
|
||||||
void rend_services_introduce(void);
|
void rend_services_introduce(void);
|
||||||
void rend_consider_services_upload(time_t now);
|
void rend_consider_services_upload(time_t now);
|
||||||
|
@ -1479,7 +1479,7 @@ rep_hist_fill_bandwidth_history(char *buf, size_t len, const bw_array_t *b)
|
|||||||
{
|
{
|
||||||
char *cp = buf;
|
char *cp = buf;
|
||||||
int i, n;
|
int i, n;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
uint64_t cutoff;
|
uint64_t cutoff;
|
||||||
|
|
||||||
if (b->num_maxes_set <= b->next_max_idx) {
|
if (b->num_maxes_set <= b->next_max_idx) {
|
||||||
|
@ -495,7 +495,7 @@ init_keys(void)
|
|||||||
char digest[DIGEST_LEN];
|
char digest[DIGEST_LEN];
|
||||||
char v3_digest[DIGEST_LEN];
|
char v3_digest[DIGEST_LEN];
|
||||||
char *cp;
|
char *cp;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
dirinfo_type_t type;
|
dirinfo_type_t type;
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
trusted_dir_server_t *ds;
|
trusted_dir_server_t *ds;
|
||||||
@ -763,7 +763,7 @@ router_reset_reachability(void)
|
|||||||
int
|
int
|
||||||
check_whether_orport_reachable(void)
|
check_whether_orport_reachable(void)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
return options->AssumeReachable ||
|
return options->AssumeReachable ||
|
||||||
can_reach_or_port;
|
can_reach_or_port;
|
||||||
}
|
}
|
||||||
@ -772,7 +772,7 @@ check_whether_orport_reachable(void)
|
|||||||
int
|
int
|
||||||
check_whether_dirport_reachable(void)
|
check_whether_dirport_reachable(void)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
return !options->DirPort ||
|
return !options->DirPort ||
|
||||||
options->AssumeReachable ||
|
options->AssumeReachable ||
|
||||||
we_are_hibernating() ||
|
we_are_hibernating() ||
|
||||||
@ -787,7 +787,7 @@ check_whether_dirport_reachable(void)
|
|||||||
* a DirPort.
|
* a DirPort.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
decide_to_advertise_dirport(or_options_t *options, uint16_t dir_port)
|
decide_to_advertise_dirport(const or_options_t *options, uint16_t dir_port)
|
||||||
{
|
{
|
||||||
static int advertising=1; /* start out assuming we will advertise */
|
static int advertising=1; /* start out assuming we will advertise */
|
||||||
int new_choice=1;
|
int new_choice=1;
|
||||||
@ -855,7 +855,7 @@ consider_testing_reachability(int test_or, int test_dir)
|
|||||||
const routerinfo_t *me = router_get_my_routerinfo();
|
const routerinfo_t *me = router_get_my_routerinfo();
|
||||||
int orport_reachable = check_whether_orport_reachable();
|
int orport_reachable = check_whether_orport_reachable();
|
||||||
tor_addr_t addr;
|
tor_addr_t addr;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
if (!me)
|
if (!me)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -973,7 +973,7 @@ router_perform_bandwidth_test(int num_circs, time_t now)
|
|||||||
* directory server.
|
* directory server.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
authdir_mode(or_options_t *options)
|
authdir_mode(const or_options_t *options)
|
||||||
{
|
{
|
||||||
return options->AuthoritativeDir != 0;
|
return options->AuthoritativeDir != 0;
|
||||||
}
|
}
|
||||||
@ -981,7 +981,7 @@ authdir_mode(or_options_t *options)
|
|||||||
* directory server.
|
* directory server.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
authdir_mode_v1(or_options_t *options)
|
authdir_mode_v1(const or_options_t *options)
|
||||||
{
|
{
|
||||||
return authdir_mode(options) && options->V1AuthoritativeDir != 0;
|
return authdir_mode(options) && options->V1AuthoritativeDir != 0;
|
||||||
}
|
}
|
||||||
@ -989,7 +989,7 @@ authdir_mode_v1(or_options_t *options)
|
|||||||
* directory server.
|
* directory server.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
authdir_mode_v2(or_options_t *options)
|
authdir_mode_v2(const or_options_t *options)
|
||||||
{
|
{
|
||||||
return authdir_mode(options) && options->V2AuthoritativeDir != 0;
|
return authdir_mode(options) && options->V2AuthoritativeDir != 0;
|
||||||
}
|
}
|
||||||
@ -997,13 +997,13 @@ authdir_mode_v2(or_options_t *options)
|
|||||||
* directory server.
|
* directory server.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
authdir_mode_v3(or_options_t *options)
|
authdir_mode_v3(const or_options_t *options)
|
||||||
{
|
{
|
||||||
return authdir_mode(options) && options->V3AuthoritativeDir != 0;
|
return authdir_mode(options) && options->V3AuthoritativeDir != 0;
|
||||||
}
|
}
|
||||||
/** Return true iff we are a v1, v2, or v3 directory authority. */
|
/** Return true iff we are a v1, v2, or v3 directory authority. */
|
||||||
int
|
int
|
||||||
authdir_mode_any_main(or_options_t *options)
|
authdir_mode_any_main(const or_options_t *options)
|
||||||
{
|
{
|
||||||
return options->V1AuthoritativeDir ||
|
return options->V1AuthoritativeDir ||
|
||||||
options->V2AuthoritativeDir ||
|
options->V2AuthoritativeDir ||
|
||||||
@ -1012,7 +1012,7 @@ authdir_mode_any_main(or_options_t *options)
|
|||||||
/** Return true if we believe ourselves to be any kind of
|
/** Return true if we believe ourselves to be any kind of
|
||||||
* authoritative directory beyond just a hidserv authority. */
|
* authoritative directory beyond just a hidserv authority. */
|
||||||
int
|
int
|
||||||
authdir_mode_any_nonhidserv(or_options_t *options)
|
authdir_mode_any_nonhidserv(const or_options_t *options)
|
||||||
{
|
{
|
||||||
return options->BridgeAuthoritativeDir ||
|
return options->BridgeAuthoritativeDir ||
|
||||||
authdir_mode_any_main(options);
|
authdir_mode_any_main(options);
|
||||||
@ -1021,7 +1021,7 @@ authdir_mode_any_nonhidserv(or_options_t *options)
|
|||||||
* authoritative about receiving and serving descriptors of type
|
* authoritative about receiving and serving descriptors of type
|
||||||
* <b>purpose</b> its dirport. Use -1 for "any purpose". */
|
* <b>purpose</b> its dirport. Use -1 for "any purpose". */
|
||||||
int
|
int
|
||||||
authdir_mode_handles_descs(or_options_t *options, int purpose)
|
authdir_mode_handles_descs(const or_options_t *options, int purpose)
|
||||||
{
|
{
|
||||||
if (purpose < 0)
|
if (purpose < 0)
|
||||||
return authdir_mode_any_nonhidserv(options);
|
return authdir_mode_any_nonhidserv(options);
|
||||||
@ -1036,7 +1036,7 @@ authdir_mode_handles_descs(or_options_t *options, int purpose)
|
|||||||
* publishes its own network statuses.
|
* publishes its own network statuses.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
authdir_mode_publishes_statuses(or_options_t *options)
|
authdir_mode_publishes_statuses(const or_options_t *options)
|
||||||
{
|
{
|
||||||
if (authdir_mode_bridge(options))
|
if (authdir_mode_bridge(options))
|
||||||
return 0;
|
return 0;
|
||||||
@ -1046,7 +1046,7 @@ authdir_mode_publishes_statuses(or_options_t *options)
|
|||||||
* tests reachability of the descriptors it learns about.
|
* tests reachability of the descriptors it learns about.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
authdir_mode_tests_reachability(or_options_t *options)
|
authdir_mode_tests_reachability(const or_options_t *options)
|
||||||
{
|
{
|
||||||
return authdir_mode_handles_descs(options, -1);
|
return authdir_mode_handles_descs(options, -1);
|
||||||
}
|
}
|
||||||
@ -1054,7 +1054,7 @@ authdir_mode_tests_reachability(or_options_t *options)
|
|||||||
* directory server.
|
* directory server.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
authdir_mode_bridge(or_options_t *options)
|
authdir_mode_bridge(const or_options_t *options)
|
||||||
{
|
{
|
||||||
return authdir_mode(options) && options->BridgeAuthoritativeDir != 0;
|
return authdir_mode(options) && options->BridgeAuthoritativeDir != 0;
|
||||||
}
|
}
|
||||||
@ -1062,7 +1062,7 @@ authdir_mode_bridge(or_options_t *options)
|
|||||||
/** Return true iff we are trying to be a server.
|
/** Return true iff we are trying to be a server.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
server_mode(or_options_t *options)
|
server_mode(const or_options_t *options)
|
||||||
{
|
{
|
||||||
if (options->ClientOnly) return 0;
|
if (options->ClientOnly) return 0;
|
||||||
return (options->ORPort != 0 || options->ORListenAddress);
|
return (options->ORPort != 0 || options->ORListenAddress);
|
||||||
@ -1071,7 +1071,7 @@ server_mode(or_options_t *options)
|
|||||||
/** Return true iff we are trying to be a non-bridge server.
|
/** Return true iff we are trying to be a non-bridge server.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
public_server_mode(or_options_t *options)
|
public_server_mode(const or_options_t *options)
|
||||||
{
|
{
|
||||||
if (!server_mode(options)) return 0;
|
if (!server_mode(options)) return 0;
|
||||||
return (!options->BridgeRelay);
|
return (!options->BridgeRelay);
|
||||||
@ -1081,7 +1081,7 @@ public_server_mode(or_options_t *options)
|
|||||||
* in the consensus mean that we don't want to allow exits from circuits
|
* in the consensus mean that we don't want to allow exits from circuits
|
||||||
* we got from addresses not known to be servers. */
|
* we got from addresses not known to be servers. */
|
||||||
int
|
int
|
||||||
should_refuse_unknown_exits(or_options_t *options)
|
should_refuse_unknown_exits(const or_options_t *options)
|
||||||
{
|
{
|
||||||
if (options->RefuseUnknownExits != -1) {
|
if (options->RefuseUnknownExits != -1) {
|
||||||
return options->RefuseUnknownExits;
|
return options->RefuseUnknownExits;
|
||||||
@ -1113,7 +1113,7 @@ set_server_advertised(int s)
|
|||||||
|
|
||||||
/** Return true iff we are trying to be a socks proxy. */
|
/** Return true iff we are trying to be a socks proxy. */
|
||||||
int
|
int
|
||||||
proxy_mode(or_options_t *options)
|
proxy_mode(const or_options_t *options)
|
||||||
{
|
{
|
||||||
return (options->SocksPort != 0 ||
|
return (options->SocksPort != 0 ||
|
||||||
options->TransPort != 0 ||
|
options->TransPort != 0 ||
|
||||||
@ -1134,7 +1134,7 @@ proxy_mode(or_options_t *options)
|
|||||||
static int
|
static int
|
||||||
decide_if_publishable_server(void)
|
decide_if_publishable_server(void)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
if (options->ClientOnly)
|
if (options->ClientOnly)
|
||||||
return 0;
|
return 0;
|
||||||
@ -1179,7 +1179,7 @@ consider_publishable_server(int force)
|
|||||||
* the one configured in the ORPort option, or the one we actually bound to
|
* the one configured in the ORPort option, or the one we actually bound to
|
||||||
* if ORPort is "auto". */
|
* if ORPort is "auto". */
|
||||||
uint16_t
|
uint16_t
|
||||||
router_get_advertised_or_port(or_options_t *options)
|
router_get_advertised_or_port(const or_options_t *options)
|
||||||
{
|
{
|
||||||
if (options->ORPort == CFG_AUTO_PORT) {
|
if (options->ORPort == CFG_AUTO_PORT) {
|
||||||
connection_t *c = connection_get_by_type(CONN_TYPE_OR_LISTENER);
|
connection_t *c = connection_get_by_type(CONN_TYPE_OR_LISTENER);
|
||||||
@ -1196,7 +1196,7 @@ router_get_advertised_or_port(or_options_t *options)
|
|||||||
* the one configured in the DirPort option,
|
* the one configured in the DirPort option,
|
||||||
* or the one we actually bound to if DirPort is "auto". */
|
* or the one we actually bound to if DirPort is "auto". */
|
||||||
uint16_t
|
uint16_t
|
||||||
router_get_advertised_dir_port(or_options_t *options, uint16_t dirport)
|
router_get_advertised_dir_port(const or_options_t *options, uint16_t dirport)
|
||||||
{
|
{
|
||||||
if (!options->DirPort)
|
if (!options->DirPort)
|
||||||
return dirport;
|
return dirport;
|
||||||
@ -1397,7 +1397,7 @@ static int router_guess_address_from_dir_headers(uint32_t *guess);
|
|||||||
* dirserver headers. Place the answer in *<b>addr</b> and return
|
* dirserver headers. Place the answer in *<b>addr</b> and return
|
||||||
* 0 on success, else return -1 if we have no guess. */
|
* 0 on success, else return -1 if we have no guess. */
|
||||||
int
|
int
|
||||||
router_pick_published_address(or_options_t *options, uint32_t *addr)
|
router_pick_published_address(const or_options_t *options, uint32_t *addr)
|
||||||
{
|
{
|
||||||
if (resolve_my_address(LOG_INFO, options, addr, NULL) < 0) {
|
if (resolve_my_address(LOG_INFO, options, addr, NULL) < 0) {
|
||||||
log_info(LD_CONFIG, "Could not determine our address locally. "
|
log_info(LD_CONFIG, "Could not determine our address locally. "
|
||||||
@ -1424,7 +1424,7 @@ router_rebuild_descriptor(int force)
|
|||||||
uint32_t addr;
|
uint32_t addr;
|
||||||
char platform[256];
|
char platform[256];
|
||||||
int hibernating = we_are_hibernating();
|
int hibernating = we_are_hibernating();
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
if (desc_clean_since && !force)
|
if (desc_clean_since && !force)
|
||||||
return 0;
|
return 0;
|
||||||
@ -1686,7 +1686,7 @@ void
|
|||||||
check_descriptor_ipaddress_changed(time_t now)
|
check_descriptor_ipaddress_changed(time_t now)
|
||||||
{
|
{
|
||||||
uint32_t prev, cur;
|
uint32_t prev, cur;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
(void) now;
|
(void) now;
|
||||||
|
|
||||||
if (!desc_routerinfo)
|
if (!desc_routerinfo)
|
||||||
@ -1718,7 +1718,7 @@ router_new_address_suggestion(const char *suggestion,
|
|||||||
{
|
{
|
||||||
uint32_t addr, cur = 0;
|
uint32_t addr, cur = 0;
|
||||||
struct in_addr in;
|
struct in_addr in;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
/* first, learn what the IP address actually is */
|
/* first, learn what the IP address actually is */
|
||||||
if (!tor_inet_aton(suggestion, &in)) {
|
if (!tor_inet_aton(suggestion, &in)) {
|
||||||
@ -1817,7 +1817,7 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
|
|||||||
int result=0;
|
int result=0;
|
||||||
addr_policy_t *tmpe;
|
addr_policy_t *tmpe;
|
||||||
char *family_line;
|
char *family_line;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
/* Make sure the identity key matches the one in the routerinfo. */
|
/* Make sure the identity key matches the one in the routerinfo. */
|
||||||
if (crypto_pk_cmp_keys(ident_key, router->identity_pkey)) {
|
if (crypto_pk_cmp_keys(ident_key, router->identity_pkey)) {
|
||||||
@ -2059,7 +2059,7 @@ int
|
|||||||
extrainfo_dump_to_string(char **s_out, extrainfo_t *extrainfo,
|
extrainfo_dump_to_string(char **s_out, extrainfo_t *extrainfo,
|
||||||
crypto_pk_env_t *ident_key)
|
crypto_pk_env_t *ident_key)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
char identity[HEX_DIGEST_LEN+1];
|
char identity[HEX_DIGEST_LEN+1];
|
||||||
char published[ISO_TIME_LEN+1];
|
char published[ISO_TIME_LEN+1];
|
||||||
char digest[DIGEST_LEN];
|
char digest[DIGEST_LEN];
|
||||||
|
@ -39,27 +39,27 @@ void router_orport_found_reachable(void);
|
|||||||
void router_dirport_found_reachable(void);
|
void router_dirport_found_reachable(void);
|
||||||
void router_perform_bandwidth_test(int num_circs, time_t now);
|
void router_perform_bandwidth_test(int num_circs, time_t now);
|
||||||
|
|
||||||
int authdir_mode(or_options_t *options);
|
int authdir_mode(const or_options_t *options);
|
||||||
int authdir_mode_v1(or_options_t *options);
|
int authdir_mode_v1(const or_options_t *options);
|
||||||
int authdir_mode_v2(or_options_t *options);
|
int authdir_mode_v2(const or_options_t *options);
|
||||||
int authdir_mode_v3(or_options_t *options);
|
int authdir_mode_v3(const or_options_t *options);
|
||||||
int authdir_mode_any_main(or_options_t *options);
|
int authdir_mode_any_main(const or_options_t *options);
|
||||||
int authdir_mode_any_nonhidserv(or_options_t *options);
|
int authdir_mode_any_nonhidserv(const or_options_t *options);
|
||||||
int authdir_mode_handles_descs(or_options_t *options, int purpose);
|
int authdir_mode_handles_descs(const or_options_t *options, int purpose);
|
||||||
int authdir_mode_publishes_statuses(or_options_t *options);
|
int authdir_mode_publishes_statuses(const or_options_t *options);
|
||||||
int authdir_mode_tests_reachability(or_options_t *options);
|
int authdir_mode_tests_reachability(const or_options_t *options);
|
||||||
int authdir_mode_bridge(or_options_t *options);
|
int authdir_mode_bridge(const or_options_t *options);
|
||||||
|
|
||||||
uint16_t router_get_advertised_or_port(or_options_t *options);
|
uint16_t router_get_advertised_or_port(const or_options_t *options);
|
||||||
uint16_t router_get_advertised_dir_port(or_options_t *options,
|
uint16_t router_get_advertised_dir_port(const or_options_t *options,
|
||||||
uint16_t dirport);
|
uint16_t dirport);
|
||||||
|
|
||||||
int server_mode(or_options_t *options);
|
int server_mode(const or_options_t *options);
|
||||||
int public_server_mode(or_options_t *options);
|
int public_server_mode(const or_options_t *options);
|
||||||
int advertised_server_mode(void);
|
int advertised_server_mode(void);
|
||||||
int proxy_mode(or_options_t *options);
|
int proxy_mode(const or_options_t *options);
|
||||||
void consider_publishable_server(int force);
|
void consider_publishable_server(int force);
|
||||||
int should_refuse_unknown_exits(or_options_t *options);
|
int should_refuse_unknown_exits(const or_options_t *options);
|
||||||
|
|
||||||
void router_upload_dir_desc_to_dirservers(int force);
|
void router_upload_dir_desc_to_dirservers(int force);
|
||||||
void mark_my_descriptor_dirty_if_older_than(time_t when);
|
void mark_my_descriptor_dirty_if_older_than(time_t when);
|
||||||
@ -77,7 +77,7 @@ int router_digest_is_me(const char *digest);
|
|||||||
int router_extrainfo_digest_is_me(const char *digest);
|
int router_extrainfo_digest_is_me(const char *digest);
|
||||||
int router_is_me(const routerinfo_t *router);
|
int router_is_me(const routerinfo_t *router);
|
||||||
int router_fingerprint_is_me(const char *fp);
|
int router_fingerprint_is_me(const char *fp);
|
||||||
int router_pick_published_address(or_options_t *options, uint32_t *addr);
|
int router_pick_published_address(const or_options_t *options, uint32_t *addr);
|
||||||
int router_rebuild_descriptor(int force);
|
int router_rebuild_descriptor(int force);
|
||||||
int router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
|
int router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
|
||||||
crypto_pk_env_t *ident_key);
|
crypto_pk_env_t *ident_key);
|
||||||
|
@ -57,7 +57,7 @@ static const char *signed_descriptor_get_body_impl(
|
|||||||
static void list_pending_downloads(digestmap_t *result,
|
static void list_pending_downloads(digestmap_t *result,
|
||||||
int purpose, const char *prefix);
|
int purpose, const char *prefix);
|
||||||
static void launch_dummy_descriptor_download_as_needed(time_t now,
|
static void launch_dummy_descriptor_download_as_needed(time_t now,
|
||||||
or_options_t *options);
|
const or_options_t *options);
|
||||||
|
|
||||||
DECLARE_TYPED_DIGESTMAP_FNS(sdmap_, digest_sd_map_t, signed_descriptor_t)
|
DECLARE_TYPED_DIGESTMAP_FNS(sdmap_, digest_sd_map_t, signed_descriptor_t)
|
||||||
DECLARE_TYPED_DIGESTMAP_FNS(rimap_, digest_ri_map_t, routerinfo_t)
|
DECLARE_TYPED_DIGESTMAP_FNS(rimap_, digest_ri_map_t, routerinfo_t)
|
||||||
@ -1077,7 +1077,7 @@ router_pick_trusteddirserver(dirinfo_type_t type, int flags)
|
|||||||
static const routerstatus_t *
|
static const routerstatus_t *
|
||||||
router_pick_directory_server_impl(dirinfo_type_t type, int flags)
|
router_pick_directory_server_impl(dirinfo_type_t type, int flags)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
const node_t *result;
|
const node_t *result;
|
||||||
smartlist_t *direct, *tunnel;
|
smartlist_t *direct, *tunnel;
|
||||||
smartlist_t *trusted_direct, *trusted_tunnel;
|
smartlist_t *trusted_direct, *trusted_tunnel;
|
||||||
@ -1200,7 +1200,7 @@ static const routerstatus_t *
|
|||||||
router_pick_trusteddirserver_impl(dirinfo_type_t type, int flags,
|
router_pick_trusteddirserver_impl(dirinfo_type_t type, int flags,
|
||||||
int *n_busy_out)
|
int *n_busy_out)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
smartlist_t *direct, *tunnel;
|
smartlist_t *direct, *tunnel;
|
||||||
smartlist_t *overloaded_direct, *overloaded_tunnel;
|
smartlist_t *overloaded_direct, *overloaded_tunnel;
|
||||||
const routerinfo_t *me = router_get_my_routerinfo();
|
const routerinfo_t *me = router_get_my_routerinfo();
|
||||||
@ -1367,7 +1367,7 @@ nodelist_add_node_family(smartlist_t *sl, const node_t *node)
|
|||||||
/* XXXX MOVE */
|
/* XXXX MOVE */
|
||||||
const smartlist_t *all_nodes = nodelist_get_list();
|
const smartlist_t *all_nodes = nodelist_get_list();
|
||||||
const smartlist_t *declared_family;
|
const smartlist_t *declared_family;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
tor_assert(node);
|
tor_assert(node);
|
||||||
|
|
||||||
@ -1456,7 +1456,7 @@ int
|
|||||||
nodes_in_same_family(const node_t *node1, const node_t *node2)
|
nodes_in_same_family(const node_t *node1, const node_t *node2)
|
||||||
{
|
{
|
||||||
/* XXXX MOVE */
|
/* XXXX MOVE */
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
/* Are they in the same family because of their addresses? */
|
/* Are they in the same family because of their addresses? */
|
||||||
if (options->EnforceDistinctSubnets) {
|
if (options->EnforceDistinctSubnets) {
|
||||||
@ -1565,7 +1565,7 @@ router_find_exact_exit_enclave(const char *address, uint16_t port)
|
|||||||
uint32_t addr;
|
uint32_t addr;
|
||||||
struct in_addr in;
|
struct in_addr in;
|
||||||
tor_addr_t a;
|
tor_addr_t a;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
if (!tor_inet_aton(address, &in))
|
if (!tor_inet_aton(address, &in))
|
||||||
return NULL; /* it's not an IP already */
|
return NULL; /* it's not an IP already */
|
||||||
@ -3267,7 +3267,7 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
|
|||||||
int from_cache, int from_fetch)
|
int from_cache, int from_fetch)
|
||||||
{
|
{
|
||||||
const char *id_digest;
|
const char *id_digest;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
int authdir = authdir_mode_handles_descs(options, router->purpose);
|
int authdir = authdir_mode_handles_descs(options, router->purpose);
|
||||||
int authdir_believes_valid = 0;
|
int authdir_believes_valid = 0;
|
||||||
routerinfo_t *old_router;
|
routerinfo_t *old_router;
|
||||||
@ -4294,7 +4294,8 @@ initiate_descriptor_downloads(const routerstatus_t *source,
|
|||||||
* running, or otherwise not a descriptor that we would make any
|
* running, or otherwise not a descriptor that we would make any
|
||||||
* use of even if we had it. Else return 1. */
|
* use of even if we had it. Else return 1. */
|
||||||
static INLINE int
|
static INLINE int
|
||||||
client_would_use_router(routerstatus_t *rs, time_t now, or_options_t *options)
|
client_would_use_router(const routerstatus_t *rs, time_t now,
|
||||||
|
const or_options_t *options)
|
||||||
{
|
{
|
||||||
if (!rs->is_flagged_running && !options->FetchUselessDescriptors) {
|
if (!rs->is_flagged_running && !options->FetchUselessDescriptors) {
|
||||||
/* If we had this router descriptor, we wouldn't even bother using it.
|
/* If we had this router descriptor, we wouldn't even bother using it.
|
||||||
@ -4347,7 +4348,7 @@ launch_descriptor_downloads(int purpose,
|
|||||||
const routerstatus_t *source, time_t now)
|
const routerstatus_t *source, time_t now)
|
||||||
{
|
{
|
||||||
int should_delay = 0, n_downloadable;
|
int should_delay = 0, n_downloadable;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
const char *descname;
|
const char *descname;
|
||||||
|
|
||||||
tor_assert(purpose == DIR_PURPOSE_FETCH_SERVERDESC ||
|
tor_assert(purpose == DIR_PURPOSE_FETCH_SERVERDESC ||
|
||||||
@ -4451,7 +4452,7 @@ update_router_descriptor_cache_downloads_v2(time_t now)
|
|||||||
digestmap_t *map; /* Which descs are in progress, or assigned? */
|
digestmap_t *map; /* Which descs are in progress, or assigned? */
|
||||||
int i, j, n;
|
int i, j, n;
|
||||||
int n_download;
|
int n_download;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
const smartlist_t *networkstatus_v2_list = networkstatus_get_v2_list();
|
const smartlist_t *networkstatus_v2_list = networkstatus_get_v2_list();
|
||||||
|
|
||||||
if (! directory_fetches_dir_info_early(options)) {
|
if (! directory_fetches_dir_info_early(options)) {
|
||||||
@ -4593,7 +4594,7 @@ void
|
|||||||
update_consensus_router_descriptor_downloads(time_t now, int is_vote,
|
update_consensus_router_descriptor_downloads(time_t now, int is_vote,
|
||||||
networkstatus_t *consensus)
|
networkstatus_t *consensus)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
digestmap_t *map = NULL;
|
digestmap_t *map = NULL;
|
||||||
smartlist_t *no_longer_old = smartlist_create();
|
smartlist_t *no_longer_old = smartlist_create();
|
||||||
smartlist_t *downloadable = smartlist_create();
|
smartlist_t *downloadable = smartlist_create();
|
||||||
@ -4723,7 +4724,8 @@ update_consensus_router_descriptor_downloads(time_t now, int is_vote,
|
|||||||
/** As needed, launch a dummy router descriptor fetch to see if our
|
/** As needed, launch a dummy router descriptor fetch to see if our
|
||||||
* address has changed. */
|
* address has changed. */
|
||||||
static void
|
static void
|
||||||
launch_dummy_descriptor_download_as_needed(time_t now, or_options_t *options)
|
launch_dummy_descriptor_download_as_needed(time_t now,
|
||||||
|
const or_options_t *options)
|
||||||
{
|
{
|
||||||
static time_t last_dummy_download = 0;
|
static time_t last_dummy_download = 0;
|
||||||
/* XXXX023 we could be smarter here; see notes on bug 652. */
|
/* XXXX023 we could be smarter here; see notes on bug 652. */
|
||||||
@ -4745,7 +4747,7 @@ launch_dummy_descriptor_download_as_needed(time_t now, or_options_t *options)
|
|||||||
void
|
void
|
||||||
update_router_descriptor_downloads(time_t now)
|
update_router_descriptor_downloads(time_t now)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
if (should_delay_dir_fetches(options))
|
if (should_delay_dir_fetches(options))
|
||||||
return;
|
return;
|
||||||
if (!we_fetch_router_descriptors(options))
|
if (!we_fetch_router_descriptors(options))
|
||||||
@ -4762,7 +4764,7 @@ update_router_descriptor_downloads(time_t now)
|
|||||||
void
|
void
|
||||||
update_extrainfo_downloads(time_t now)
|
update_extrainfo_downloads(time_t now)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
routerlist_t *rl;
|
routerlist_t *rl;
|
||||||
smartlist_t *wanted;
|
smartlist_t *wanted;
|
||||||
digestmap_t *pending;
|
digestmap_t *pending;
|
||||||
@ -4884,7 +4886,7 @@ get_dir_info_status_string(void)
|
|||||||
static void
|
static void
|
||||||
count_usable_descriptors(int *num_present, int *num_usable,
|
count_usable_descriptors(int *num_present, int *num_usable,
|
||||||
const networkstatus_t *consensus,
|
const networkstatus_t *consensus,
|
||||||
or_options_t *options, time_t now,
|
const or_options_t *options, time_t now,
|
||||||
routerset_t *in_set)
|
routerset_t *in_set)
|
||||||
{
|
{
|
||||||
const int md = (consensus->flavor == FLAV_MICRODESC);
|
const int md = (consensus->flavor == FLAV_MICRODESC);
|
||||||
@ -4950,7 +4952,7 @@ update_router_have_minimum_dir_info(void)
|
|||||||
int num_present = 0, num_usable=0;
|
int num_present = 0, num_usable=0;
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
int res;
|
int res;
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
const networkstatus_t *consensus =
|
const networkstatus_t *consensus =
|
||||||
networkstatus_get_reasonably_live_consensus(now,usable_consensus_flavor());
|
networkstatus_get_reasonably_live_consensus(now,usable_consensus_flavor());
|
||||||
|
|
||||||
@ -5497,7 +5499,7 @@ routerset_parse(routerset_t *target, const char *s, const char *description)
|
|||||||
void
|
void
|
||||||
refresh_all_country_info(void)
|
refresh_all_country_info(void)
|
||||||
{
|
{
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
if (options->EntryNodes)
|
if (options->EntryNodes)
|
||||||
routerset_refresh_countries(options->EntryNodes);
|
routerset_refresh_countries(options->EntryNodes);
|
||||||
|
@ -85,7 +85,7 @@ log_heartbeat(time_t now)
|
|||||||
char *uptime = NULL;
|
char *uptime = NULL;
|
||||||
const routerinfo_t *me;
|
const routerinfo_t *me;
|
||||||
|
|
||||||
or_options_t *options = get_options();
|
const or_options_t *options = get_options();
|
||||||
(void)now;
|
(void)now;
|
||||||
|
|
||||||
if (public_server_mode(options)) {
|
if (public_server_mode(options)) {
|
||||||
|
@ -1074,8 +1074,8 @@ test_geoip(void)
|
|||||||
test_streq("??", NAMEFOR(2000));
|
test_streq("??", NAMEFOR(2000));
|
||||||
#undef NAMEFOR
|
#undef NAMEFOR
|
||||||
|
|
||||||
get_options()->BridgeRelay = 1;
|
get_options_mutable()->BridgeRelay = 1;
|
||||||
get_options()->BridgeRecordUsageByCountry = 1;
|
get_options_mutable()->BridgeRecordUsageByCountry = 1;
|
||||||
/* Put 9 observations in AB... */
|
/* Put 9 observations in AB... */
|
||||||
for (i=32; i < 40; ++i)
|
for (i=32; i < 40; ++i)
|
||||||
geoip_note_client_seen(GEOIP_CLIENT_CONNECT, i, now-7200);
|
geoip_note_client_seen(GEOIP_CLIENT_CONNECT, i, now-7200);
|
||||||
|
@ -56,7 +56,7 @@ test_md_cache(void *data)
|
|||||||
char *fn = NULL, *s = NULL;
|
char *fn = NULL, *s = NULL;
|
||||||
(void)data;
|
(void)data;
|
||||||
|
|
||||||
options = get_options();
|
options = get_options_mutable();
|
||||||
tt_assert(options);
|
tt_assert(options);
|
||||||
|
|
||||||
time1 = time(NULL);
|
time1 = time(NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user