Move TestingDirAuthTimeToLearnReachability into dirauth module.

This commit is contained in:
Nick Mathewson
2019-12-19 10:00:25 -05:00
parent be9bc5981f
commit cde5abfdc6
6 changed files with 31 additions and 28 deletions
-1
View File
@@ -392,7 +392,6 @@ static const config_var_t option_vars_[] = {
V(DisableOOSCheck, BOOL, "1"),
V(DisableNetwork, BOOL, "0"),
V(DirAllowPrivateAddresses, BOOL, "0"),
V(TestingAuthDirTimeToLearnReachability, INTERVAL, "30 minutes"),
OBSOLETE("DirListenAddress"),
V(DirPolicy, LINELIST, NULL),
VPORT(DirPort),
-5
View File
@@ -686,11 +686,6 @@ struct or_options_t {
voting. Only altered on testing networks. */
int TestingV3AuthVotingStartOffset;
/** If an authority has been around for less than this amount of time, it
* does not believe its reachability information is accurate. Only
* altered on testing networks. */
int TestingAuthDirTimeToLearnReachability;
/** Clients don't download any descriptor this recent, since it will
* probably not have propagated to enough caches. Only altered on testing
* networks. */
+6 -6
View File
@@ -213,12 +213,6 @@ options_validate_dirauth_testing(const or_options_t *old_options,
if (!authdir_mode(options))
return 0;
if (options->TestingAuthDirTimeToLearnReachability < 0) {
REJECT("TestingAuthDirTimeToLearnReachability must be non-negative.");
} else if (options->TestingAuthDirTimeToLearnReachability > 2*60*60) {
COMPLAIN("TestingAuthDirTimeToLearnReachability is insanely high.");
}
if (!authdir_mode_v3(options))
return 0;
@@ -443,6 +437,12 @@ dirauth_options_validate(const void *arg, char **msg)
t = format_recommended_version_list(options->RecommendedServerVersions, 1);
tor_free(t);
if (options->TestingAuthDirTimeToLearnReachability < 0) {
REJECT("TestingAuthDirTimeToLearnReachability must be non-negative.");
} else if (options->TestingAuthDirTimeToLearnReachability > 2*60*60) {
COMPLAIN("TestingAuthDirTimeToLearnReachability is insanely high.");
}
return 0;
}
+5
View File
@@ -65,6 +65,11 @@ CONF_VAR(RecommendedClientVersions, LINELIST, 0, NULL)
/** Which versions of tor should we tell users to run on relays? */
CONF_VAR(RecommendedServerVersions, LINELIST, 0, NULL)
/** If an authority has been around for less than this amount of time, it
* does not believe its reachability information is accurate. Only
* altered on testing networks. */
CONF_VAR(TestingAuthDirTimeToLearnReachability, INTERVAL, 0, "30 minutes")
/** Boolean: is this an authoritative directory that's willing to recommend
* versions? */
CONF_VAR(VersioningAuthoritativeDirectory, BOOL, 0, "0")
+3 -2
View File
@@ -460,8 +460,9 @@ dirserv_get_flag_thresholds_line(void)
int
running_long_enough_to_decide_unreachable(void)
{
return time_of_process_start
+ get_options()->TestingAuthDirTimeToLearnReachability < approx_time();
const dirauth_options_t *opts = dirauth_get_options();
return time_of_process_start +
opts->TestingAuthDirTimeToLearnReachability < approx_time();
}
/** Each server needs to have passed a reachability test no more
+17 -14
View File
@@ -3851,14 +3851,15 @@ test_options_validate__testing_options(void *ignored)
options_test_data_t *tdata = NULL;
setup_capture_of_logs(LOG_WARN);
#define TEST_TESTING_OPTION(name, low_val, high_val, err_low, EXTRA_OPT_STR) \
#define TEST_TESTING_OPTION(name, accessor, \
low_val, high_val, err_low, EXTRA_OPT_STR) \
STMT_BEGIN \
free_options_test_data(tdata); \
tdata = get_options_test_data(EXTRA_OPT_STR \
VALID_DIR_AUTH \
"TestingTorNetwork 1\n" \
); \
tdata->opt-> name = low_val; \
accessor(tdata->opt)->name = low_val; \
ret = options_validate(NULL, tdata->opt, &msg); \
tt_int_op(ret, OP_EQ, -1); \
tt_str_op(msg, OP_EQ, #name " " err_low); \
@@ -3869,7 +3870,7 @@ test_options_validate__testing_options(void *ignored)
VALID_DIR_AUTH \
"TestingTorNetwork 1\n" \
); \
tdata->opt-> name = high_val; \
accessor(tdata->opt)->name = high_val; \
mock_clean_saved_logs(); \
ret = options_validate(NULL, tdata->opt, &msg); \
tt_int_op(ret, OP_EQ, 0); \
@@ -3878,30 +3879,32 @@ test_options_validate__testing_options(void *ignored)
tor_free(msg); \
STMT_END
TEST_TESTING_OPTION(TestingAuthDirTimeToLearnReachability, -1, 8000,
TEST_TESTING_OPTION(TestingAuthDirTimeToLearnReachability,
get_dirauth_options, -1, 8000,
"must be non-negative.", ENABLE_AUTHORITY_V3);
TEST_TESTING_OPTION(TestingAuthDirTimeToLearnReachability, -1, 8000,
TEST_TESTING_OPTION(TestingAuthDirTimeToLearnReachability,
get_dirauth_options, -1, 8000,
"must be non-negative.", ENABLE_AUTHORITY_BRIDGE);
TEST_TESTING_OPTION(TestingEstimatedDescriptorPropagationTime, -1, 3601,
TEST_TESTING_OPTION(TestingEstimatedDescriptorPropagationTime, , -1, 3601,
"must be non-negative.", "");
TEST_TESTING_OPTION(TestingClientMaxIntervalWithoutRequest, -1, 3601,
TEST_TESTING_OPTION(TestingClientMaxIntervalWithoutRequest, , -1, 3601,
"is way too low.", "");
TEST_TESTING_OPTION(TestingDirConnectionMaxStall, 1, 3601,
TEST_TESTING_OPTION(TestingDirConnectionMaxStall, , 1, 3601,
"is way too low.", "");
TEST_TESTING_OPTION(TestingEstimatedDescriptorPropagationTime, -1, 3601,
TEST_TESTING_OPTION(TestingEstimatedDescriptorPropagationTime, , -1, 3601,
"must be non-negative.", ENABLE_AUTHORITY_V3);
TEST_TESTING_OPTION(TestingClientMaxIntervalWithoutRequest, -1, 3601,
TEST_TESTING_OPTION(TestingClientMaxIntervalWithoutRequest, , -1, 3601,
"is way too low.", ENABLE_AUTHORITY_V3);
TEST_TESTING_OPTION(TestingDirConnectionMaxStall, 1, 3601,
TEST_TESTING_OPTION(TestingDirConnectionMaxStall, , 1, 3601,
"is way too low.", ENABLE_AUTHORITY_V3);
TEST_TESTING_OPTION(TestingEstimatedDescriptorPropagationTime, -1, 3601,
TEST_TESTING_OPTION(TestingEstimatedDescriptorPropagationTime, , -1, 3601,
"must be non-negative.", ENABLE_AUTHORITY_BRIDGE);
TEST_TESTING_OPTION(TestingClientMaxIntervalWithoutRequest, -1, 3601,
TEST_TESTING_OPTION(TestingClientMaxIntervalWithoutRequest, , -1, 3601,
"is way too low.", ENABLE_AUTHORITY_BRIDGE);
TEST_TESTING_OPTION(TestingDirConnectionMaxStall, 1, 3601,
TEST_TESTING_OPTION(TestingDirConnectionMaxStall, , 1, 3601,
"is way too low.", ENABLE_AUTHORITY_BRIDGE);
free_options_test_data(tdata);