41 STMT_BEGIN *msg = tor_strdup(arg); return -1; STMT_END
42#if defined(__GNUC__) && __GNUC__ <= 3
43#define COMPLAIN(args...) \
44 STMT_BEGIN log_warn(LD_CONFIG, args); STMT_END
46#define COMPLAIN(args, ...) \
47 STMT_BEGIN log_warn(LD_CONFIG, args, ##__VA_ARGS__); STMT_END
50#define YES_IF_CHANGED_INT(opt) \
51 if (!CFG_EQ_INT(old_options, new_options, opt)) return 1;
85 REJECT(
"Failed to resolve/guess local address. See logs for details.");
88 REJECT(
"Authoritative directory servers must set ContactInfo");
91 log_info(
LD_CONFIG,
"Authoritative directory servers can't set "
92 "UseEntryGuards. Disabling.");
96 log_info(
LD_CONFIG,
"Authoritative directories always try to download "
97 "extra-info documents. Setting DownloadExtraInfo.");
102 REJECT(
"AuthoritativeDir is set, but none of "
103 "(Bridge/V3)AuthoritativeDir is set.");
115 if (!options->DirPort_set)
116 REJECT(
"Running as authoritative directory, but no DirPort set.");
118 if (!options->ORPort_set)
119 REJECT(
"Running as authoritative directory, but no ORPort set.");
122 REJECT(
"Running as authoritative directory, but ClientOnly also set.");
147 if (!authdir_mode_v3(options))
152 REJECT(
"V3AuthVoteDelay plus V3AuthDistDelay must be less than half "
153 "V3AuthVotingInterval");
159 REJECT(
"V3AuthVoteDelay is way too low.");
161 COMPLAIN(
"V3AuthVoteDelay is very low. "
162 "This may lead to failure to vote for a consensus.");
165 REJECT(
"V3AuthVoteDelay is way too low.");
172 REJECT(
"V3AuthDistDelay is way too low.");
174 COMPLAIN(
"V3AuthDistDelay is very low. "
175 "This may lead to missing votes in a consensus.");
178 REJECT(
"V3AuthDistDelay is way too low.");
183 REJECT(
"V3AuthNIntervalsValid must be at least 2.");
189 REJECT(
"V3AuthVotingInterval is insanely low.");
191 COMPLAIN(
"V3AuthVotingInterval is very low. "
192 "This may lead to failure to synchronise for a consensus.");
195 REJECT(
"V3AuthVotingInterval is insanely low.");
198 REJECT(
"V3AuthVotingInterval is insanely high.");
200 COMPLAIN(
"V3AuthVotingInterval does not divide evenly into 24 hours.");
229 if (!authdir_mode_v3(options))
233 < MIN_VOTE_INTERVAL_TESTING_INITIAL) {
234 REJECT(
"TestingV3AuthInitialVotingInterval is insanely low.");
236 REJECT(
"TestingV3AuthInitialVotingInterval does not divide evenly into "
241 REJECT(
"TestingV3AuthInitialVoteDelay is way too low.");
245 REJECT(
"TestingV3AuthInitialDistDelay is way too low.");
251 REJECT(
"TestingV3AuthInitialVoteDelay plus TestingV3AuthInitialDistDelay "
252 "must be less than TestingV3AuthInitialVotingInterval");
258 REJECT(
"TestingV3AuthVotingStartOffset is higher than the voting "
261 REJECT(
"TestingV3AuthVotingStartOffset must be non-negative.");
278 if (authdir_mode_v3(old_options) != authdir_mode_v3(new_options))
280 if (! authdir_mode_v3(new_options))
283 YES_IF_CHANGED_INT(V3AuthVotingInterval);
284 YES_IF_CHANGED_INT(V3AuthVoteDelay);
285 YES_IF_CHANGED_INT(V3AuthDistDelay);
286 YES_IF_CHANGED_INT(TestingV3AuthInitialVotingInterval);
287 YES_IF_CHANGED_INT(TestingV3AuthInitialVoteDelay);
288 YES_IF_CHANGED_INT(TestingV3AuthInitialDistDelay);
289 YES_IF_CHANGED_INT(TestingV3AuthVotingStartOffset);
366 bool *print_notice_out)
368 if (BUG(!print_notice_out))
374 time_t now = time(NULL);
375 int print_notice = 0;
382 *print_notice_out = 1;
413 "AuthDirFastGuarantee", msg_out) < 0)
416 "AuthDirGuardBWGuarantee", msg_out) < 0)
432 tor_version_t minimal_accepted_server_version, recommended_version;
437 REJECT(
"Versioning authoritative dir servers must set "
438 "Recommended*Versions.");
443 REJECT(
"Guard bandwdith threshold fraction is invalid.");
447 &minimal_accepted_server_version) != 0) {
448 REJECT(
"Invalid MinimalAcceptedServerVersion");
452 &recommended_version) == 0,
453 "We failed to parse our own version");
455 &minimal_accepted_server_version) < 0) {
456 REJECT(
"MinimalAcceptedServerVersion wants to reject the version "
457 "this node is running");
460 char *recommended_versions;
461 int found_recommended_rejected_version = 0;
472 SPLIT_SKIP_SPACE, 0);
475 &recommended_version) != 0) {
476 COMPLAIN(
"Found unparseable version in RecommendedServerVersions");
481 &minimal_accepted_server_version) < 0) {
482 found_recommended_rejected_version = 1;
485 } SMARTLIST_FOREACH_END(version);
488 smartlist_free(version_sl);
490 if (found_recommended_rejected_version)
491 REJECT(
"MinimalAcceptedServerVersion wants to reject a recommended "
495 COMPLAIN(
"TestingAuthDirTimeToLearnReachability is insanely high.");
502#define CONF_CONTEXT TABLE
507#define DIRAUTH_OPTIONS_MAGIC 0x41757448
514 .magic = {
"dirauth_options_t",
517 .vars = dirauth_options_t_vars,
int authdir_mode(const or_options_t *options)
int authdir_mode_bridge(const or_options_t *options)
Header file for directory authority mode.
int dirserv_read_measured_bandwidths(const char *from_file, smartlist_t *routerstatuses, smartlist_t *bw_file_headers, uint8_t *digest_out)
Header file for bwauth.c.
Macros for generating a configuration struct from a list of its individual fields.
int config_ensure_bandwidth_cap(uint64_t *value, const char *desc, char **msg)
const or_options_t * get_options(void)
Header file for config.c.
config_line_t * config_lines_dup(const config_line_t *inp)
int options_act_dirauth_mtbf(const or_options_t *old_options)
static int dirauth_options_validate(const void *arg, char **msg)
const config_format_t dirauth_options_fmt
bool dirauth_should_reject_requests_under_load(void)
int options_act_dirauth_stats(const or_options_t *old_options, bool *print_notice_out)
int options_validate_dirauth_mode(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)
static int dirauth_options_pre_normalize(void *arg, char **msg_out)
int options_act_dirauth(const or_options_t *old_options)
#define DIRAUTH_OPTIONS_MAGIC
int options_validate_dirauth_testing(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)
Header for feature/dirauth/dirauth_config.c.
Declare configuration options for the crypto_ops module.
Structure dirauth_options_t to hold directory authority options.
void reschedule_dirvote(const or_options_t *options)
Header for dirauth_periodic.c.
Header for dirauth_sys.c.
char * format_recommended_version_list(const config_line_t *ln, int warn)
Header file for dirvote.c.
#define MIN_DIST_SECONDS_TESTING
#define MIN_VOTE_INTERVAL_TESTING
#define MIN_VOTE_INTERVAL
#define MIN_VOTE_SECONDS_TESTING
Header file for guardfraction.c.
int dirserv_read_guardfraction_file(const char *fname, smartlist_t *vote_routerstatuses)
Master header file for Tor-specific functionality.
void rep_hist_desc_stats_term(void)
int rep_hist_load_mtbf_data(time_t now)
void rep_hist_desc_stats_init(time_t now)
Header file for rephist.c.
bool find_my_address(const or_options_t *options, int family, int warn_severity, tor_addr_t *addr_out, resolved_addr_method_t *method_out, char **hostname_out)
Attempt to find our IP address that can be used as our external reachable address.
Header file for resolve_addr.c.
smartlist_t * smartlist_new(void)
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
#define SMARTLIST_FOREACH(sl, type, var, cmd)
int smartlist_split_string(smartlist_t *sl, const char *str, const char *sep, int flags, int max)
MEMUNIT AuthDirFastGuarantee
MEMUNIT AuthDirGuardBWGuarantee
DOUBLE AuthDirVoteGuardBwThresholdFraction
STRING MinimalAcceptedServerVersion
INTERVAL TestingAuthDirTimeToLearnReachability
LINELIST RecommendedServerVersions
BOOL VersioningAuthoritativeDirectory
LINELIST RecommendedClientVersions
LINELIST RecommendedVersions
BOOL AuthDirRejectRequestsUnderLoad
int TestingV3AuthInitialDistDelay
int V3AuthNIntervalsValid
int TestingV3AuthInitialVotingInterval
int TestingV3AuthInitialVoteDelay
tor_cmdline_mode_t command
int BridgeAuthoritativeDir
int TestingV3AuthVotingStartOffset
Parsed Tor version structure.
const char * get_short_version(void)
int tor_version_compare(tor_version_t *a, tor_version_t *b)
int tor_version_parse(const char *s, tor_version_t *out)
Header file for versions.c.
void dirauth_sched_recalculate_timing(const or_options_t *options, time_t now)
Header file for voting_schedule.c.