Tor  0.4.5.0-alpha-dev
Macros | Functions | Variables
dirauth_config.c File Reference

Code to interpret the user's configuration of Tor's directory authority module. More...

#include "orconfig.h"
#include "feature/dirauth/dirauth_config.h"
#include "lib/encoding/confline.h"
#include "lib/confmgt/confmgt.h"
#include "lib/conf/confdecl.h"
#include "core/or/or.h"
#include "app/config/config.h"
#include "app/config/resolve_addr.h"
#include "feature/dirauth/voting_schedule.h"
#include "feature/stats/rephist.h"
#include "feature/dirauth/authmode.h"
#include "feature/dirauth/bwauth.h"
#include "feature/dirauth/dirauth_periodic.h"
#include "feature/dirauth/dirauth_sys.h"
#include "feature/dirauth/dirvote.h"
#include "feature/dirauth/guardfraction.h"
#include "feature/dirauth/dirauth_options_st.h"
#include "feature/dirauth/dirauth_options.inc"

Go to the source code of this file.

Macros

#define REJECT(arg)    STMT_BEGIN *msg = tor_strdup(arg); return -1; STMT_END
 
#define COMPLAIN(args, ...)    STMT_BEGIN log_warn(LD_CONFIG, args, ##__VA_ARGS__); STMT_END
 
#define YES_IF_CHANGED_INT(opt)    if (!CFG_EQ_INT(old_options, new_options, opt)) return 1;
 
#define CONF_CONTEXT   TABLE
 
#define DIRAUTH_OPTIONS_MAGIC   0x41757448
 

Functions

bool dirauth_should_reject_requests_under_load (void)
 
int options_validate_dirauth_mode (const or_options_t *old_options, or_options_t *options, char **msg)
 
int options_validate_dirauth_schedule (const or_options_t *old_options, or_options_t *options, char **msg)
 
int options_validate_dirauth_testing (const or_options_t *old_options, or_options_t *options, char **msg)
 
static int options_transition_affects_dirauth_timing (const or_options_t *old_options, const or_options_t *new_options)
 
int options_act_dirauth (const or_options_t *old_options)
 
int options_act_dirauth_mtbf (const or_options_t *old_options)
 
int options_act_dirauth_stats (const or_options_t *old_options, bool *print_notice_out)
 
static int dirauth_options_pre_normalize (void *arg, char **msg_out)
 
static int dirauth_options_validate (const void *arg, char **msg)
 

Variables

const config_format_t dirauth_options_fmt
 

Detailed Description

Code to interpret the user's configuration of Tor's directory authority module.

Definition in file dirauth_config.c.

Macro Definition Documentation

◆ DIRAUTH_OPTIONS_MAGIC

#define DIRAUTH_OPTIONS_MAGIC   0x41757448

Magic number for dirauth_options_t.

Definition at line 457 of file dirauth_config.c.

Function Documentation

◆ dirauth_options_pre_normalize()

static int dirauth_options_pre_normalize ( void *  arg,
char **  msg_out 
)
static

Make any necessary modifications to a dirauth_options_t that occur before validation. On success return 0; on failure return -1 and set *msg_out to a newly allocated error string.

Definition at line 397 of file dirauth_config.c.

◆ dirauth_options_validate()

static int dirauth_options_validate ( const void *  arg,
char **  msg 
)
static

Check whether a dirauth_options_t is correct.

On success return 0; on failure return -1 and set *msg_out to a newly allocated error string.

Definition at line 426 of file dirauth_config.c.

◆ dirauth_should_reject_requests_under_load()

bool dirauth_should_reject_requests_under_load ( void  )

Return true iff we are configured to reject request under load for non relay connections.

Definition at line 53 of file dirauth_config.c.

◆ options_act_dirauth()

int options_act_dirauth ( const or_options_t old_options)

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

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

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

Definition at line 302 of file dirauth_config.c.

◆ options_act_dirauth_mtbf()

int options_act_dirauth_mtbf ( const or_options_t old_options)

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

Must be called immediately after a successful or_state_load().

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

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

Definition at line 330 of file dirauth_config.c.

◆ options_act_dirauth_stats()

int options_act_dirauth_stats ( const or_options_t old_options,
bool *  print_notice_out 
)

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

Sets *print_notice_out if we enabled stats, and need to print a stats log using options_act_relay_stats_msg().

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

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

Definition at line 362 of file dirauth_config.c.

◆ options_transition_affects_dirauth_timing()

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

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

Definition at line 269 of file dirauth_config.c.

Referenced by options_act_dirauth().

◆ options_validate_dirauth_mode()

int options_validate_dirauth_mode ( const or_options_t old_options,
or_options_t options,
char **  msg 
)

Legacy validation/normalization function for the dirauth mode options in options. Uses old_options as the previous options.

Returns 0 on success, returns -1 and sets *msg to a newly allocated string on error.

Definition at line 66 of file dirauth_config.c.

◆ options_validate_dirauth_schedule()

int options_validate_dirauth_schedule ( const or_options_t old_options,
or_options_t options,
char **  msg 
)

Legacy validation/normalization function for the dirauth schedule options in options. Uses old_options as the previous options.

Returns 0 on success, returns -1 and sets *msg to a newly allocated string on error.

Definition at line 132 of file dirauth_config.c.

◆ options_validate_dirauth_testing()

int options_validate_dirauth_testing ( const or_options_t old_options,
or_options_t options,
char **  msg 
)

Legacy validation/normalization function for the dirauth testing options in options. Uses old_options as the previous options.

Returns 0 on success, returns -1 and sets *msg to a newly allocated string on error.

Definition at line 211 of file dirauth_config.c.

Variable Documentation

◆ dirauth_options_fmt

const config_format_t dirauth_options_fmt
Initial value:
= {
.size = sizeof(dirauth_options_t),
.magic = { "dirauth_options_t",
offsetof(dirauth_options_t, magic) },
.vars = dirauth_options_t_vars,
.pre_normalize_fn = dirauth_options_pre_normalize,
.validate_fn = dirauth_options_validate
}

Declare the configuration options for the dirauth module.

Definition at line 462 of file dirauth_config.c.

dirauth_options_validate
static int dirauth_options_validate(const void *arg, char **msg)
Definition: dirauth_config.c:426
dirauth_options_t
Definition: dirauth_options.inc:13
DIRAUTH_OPTIONS_MAGIC
#define DIRAUTH_OPTIONS_MAGIC
Definition: dirauth_config.c:457
dirauth_options_pre_normalize
static int dirauth_options_pre_normalize(void *arg, char **msg_out)
Definition: dirauth_config.c:397