summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-12-19 10:00:25 -0500
committerNick Mathewson <nickm@torproject.org>2019-12-19 10:08:22 -0500
commitcde5abfdc6381e618f9649dd00f74d91d65848d7 (patch)
tree53dcc2493f7f437ef495c1a19f1ab3da9fea4bf1
parentbe9bc5981f21a73508e32207fd197b513a6f01be (diff)
downloadtor-cde5abfdc6381e618f9649dd00f74d91d65848d7.tar.gz
tor-cde5abfdc6381e618f9649dd00f74d91d65848d7.zip
Move TestingDirAuthTimeToLearnReachability into dirauth module.
-rw-r--r--src/app/config/config.c1
-rw-r--r--src/app/config/or_options_st.h5
-rw-r--r--src/feature/dirauth/dirauth_config.c12
-rw-r--r--src/feature/dirauth/dirauth_options.inc5
-rw-r--r--src/feature/dirauth/voteflags.c5
-rw-r--r--src/test/test_options.c31
6 files changed, 31 insertions, 28 deletions
diff --git a/src/app/config/config.c b/src/app/config/config.c
index 262013de4c..3e1549b705 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -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),
diff --git a/src/app/config/or_options_st.h b/src/app/config/or_options_st.h
index 2796aaba78..a38eae40f6 100644
--- a/src/app/config/or_options_st.h
+++ b/src/app/config/or_options_st.h
@@ -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. */
diff --git a/src/feature/dirauth/dirauth_config.c b/src/feature/dirauth/dirauth_config.c
index e3f06e9e8a..4a3f569966 100644
--- a/src/feature/dirauth/dirauth_config.c
+++ b/src/feature/dirauth/dirauth_config.c
@@ -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;
}
diff --git a/src/feature/dirauth/dirauth_options.inc b/src/feature/dirauth/dirauth_options.inc
index d5ae09cf27..e1550a6e90 100644
--- a/src/feature/dirauth/dirauth_options.inc
+++ b/src/feature/dirauth/dirauth_options.inc
@@ -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")
diff --git a/src/feature/dirauth/voteflags.c b/src/feature/dirauth/voteflags.c
index 97cb2eb726..757bc35941 100644
--- a/src/feature/dirauth/voteflags.c
+++ b/src/feature/dirauth/voteflags.c
@@ -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
diff --git a/src/test/test_options.c b/src/test/test_options.c
index 3465207166..10e79c48d8 100644
--- a/src/test/test_options.c
+++ b/src/test/test_options.c
@@ -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);