[tor-commits] [tor/master] Move MinUptimeHidServDirectoryV2 to dirauth module.
nickm at torproject.org
nickm at torproject.org
Fri Jan 17 13:37:45 UTC 2020
commit 77dea66e19404a4c07f0e738efb7710f542037ed
Author: Nick Mathewson <nickm at torproject.org>
Date: Thu Dec 19 09:43:25 2019 -0500
Move MinUptimeHidServDirectoryV2 to dirauth module.
---
src/app/config/config.c | 1 -
src/app/config/or_options_st.h | 3 ---
src/feature/dirauth/dirauth_config.c | 12 ++++++------
src/feature/dirauth/dirauth_options.inc | 4 ++++
src/feature/dirauth/voteflags.c | 6 +++---
src/test/test_options.c | 5 +++--
6 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/src/app/config/config.c b/src/app/config/config.c
index 06a0110e4..4b47894cc 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -712,7 +712,6 @@ static const config_var_t option_vars_[] = {
OwningControllerProcess, NULL),
VAR_NODUMP_IMMUTABLE("__OwningControllerFD", UINT64, OwningControllerFD,
UINT64_MAX_STRING),
- V(MinUptimeHidServDirectoryV2, INTERVAL, "96 hours"),
V(TestingServerDownloadInitialDelay, CSV_INTERVAL, "0"),
V(TestingClientDownloadInitialDelay, CSV_INTERVAL, "0"),
V(TestingServerConsensusDownloadInitialDelay, CSV_INTERVAL, "0"),
diff --git a/src/app/config/or_options_st.h b/src/app/config/or_options_st.h
index 46c709622..09edc21a7 100644
--- a/src/app/config/or_options_st.h
+++ b/src/app/config/or_options_st.h
@@ -257,9 +257,6 @@ struct or_options_t {
int FetchServerDescriptors; /**< Do we fetch server descriptors as normal? */
int FetchHidServDescriptors; /**< and hidden service descriptors? */
- int MinUptimeHidServDirectoryV2; /**< As directory authority, accept hidden
- * service directories after what time? */
-
int FetchUselessDescriptors; /**< Do we fetch non-running descriptors too? */
int AllDirActionsPrivate; /**< Should every directory action be sent
* through a Tor circuit? */
diff --git a/src/feature/dirauth/dirauth_config.c b/src/feature/dirauth/dirauth_config.c
index ccece9721..e3f06e9e8 100644
--- a/src/feature/dirauth/dirauth_config.c
+++ b/src/feature/dirauth/dirauth_config.c
@@ -108,12 +108,6 @@ options_validate_dirauth_mode(const or_options_t *old_options,
if (options->ClientOnly)
REJECT("Running as authoritative directory, but ClientOnly also set.");
- if (options->MinUptimeHidServDirectoryV2 < 0) {
- log_warn(LD_CONFIG, "MinUptimeHidServDirectoryV2 option must be at "
- "least 0 seconds. Changing to 0.");
- options->MinUptimeHidServDirectoryV2 = 0;
- }
-
return 0;
}
@@ -415,6 +409,12 @@ dirauth_options_pre_normalize(void *arg, char **msg_out)
"AuthDirGuardBWGuarantee", msg_out) < 0)
return -1;
+ if (options->MinUptimeHidServDirectoryV2 < 0) {
+ log_warn(LD_CONFIG, "MinUptimeHidServDirectoryV2 option must be at "
+ "least 0 seconds. Changing to 0.");
+ options->MinUptimeHidServDirectoryV2 = 0;
+ }
+
return 0;
}
diff --git a/src/feature/dirauth/dirauth_options.inc b/src/feature/dirauth/dirauth_options.inc
index ca70a51b9..f0aadb006 100644
--- a/src/feature/dirauth/dirauth_options.inc
+++ b/src/feature/dirauth/dirauth_options.inc
@@ -44,6 +44,10 @@ CONF_VAR(AuthDirSharedRandomness, BOOL, 0, "1")
/* NOTE: remove this option someday. */
CONF_VAR(AuthDirTestEd25519LinkKeys, BOOL, 0, "1")
+/** As directory authority, accept hidden service directories after what
+ * time? */
+CONF_VAR(MinUptimeHidServDirectoryV2, INTERVAL, 0, "96 hours")
+
/** Which versions of tor should we tell users to run? */
CONF_VAR(RecommendedVersions, LINELIST, 0, NULL)
diff --git a/src/feature/dirauth/voteflags.c b/src/feature/dirauth/voteflags.c
index 8b9b8bc5c..d0bc30d4c 100644
--- a/src/feature/dirauth/voteflags.c
+++ b/src/feature/dirauth/voteflags.c
@@ -177,14 +177,14 @@ dirserv_thinks_router_is_hs_dir(const routerinfo_t *router,
long uptime;
/* If we haven't been running for at least
- * get_options()->MinUptimeHidServDirectoryV2 seconds, we can't
+ * MinUptimeHidServDirectoryV2 seconds, we can't
* have accurate data telling us a relay has been up for at least
* that long. We also want to allow a bit of slack: Reachability
* tests aren't instant. If we haven't been running long enough,
* trust the relay. */
if (get_uptime() >
- get_options()->MinUptimeHidServDirectoryV2 * 1.1)
+ dirauth_get_options()->MinUptimeHidServDirectoryV2 * 1.1)
uptime = MIN(rep_hist_get_uptime(router->cache_info.identity_digest, now),
real_uptime(router, now));
else
@@ -193,7 +193,7 @@ dirserv_thinks_router_is_hs_dir(const routerinfo_t *router,
return (router->wants_to_be_hs_dir &&
router->supports_tunnelled_dir_requests &&
node->is_stable && node->is_fast &&
- uptime >= get_options()->MinUptimeHidServDirectoryV2 &&
+ uptime >= dirauth_get_options()->MinUptimeHidServDirectoryV2 &&
router_is_active(router, node, now));
}
diff --git a/src/test/test_options.c b/src/test/test_options.c
index 1649a2586..346520716 100644
--- a/src/test/test_options.c
+++ b/src/test/test_options.c
@@ -994,13 +994,14 @@ test_options_validate__authdir(void *ignored)
free_options_test_data(tdata);
tdata = get_options_test_data(ENABLE_AUTHORITY_V3);
/* We have to set this value manually, because it won't parse */
- tdata->opt->MinUptimeHidServDirectoryV2 = -1;
+ get_dirauth_options(tdata->opt)->MinUptimeHidServDirectoryV2 = -1;
mock_clean_saved_logs();
ret = options_validate(NULL, tdata->opt, &msg);
tt_int_op(ret, OP_EQ, 0);
expect_log_msg("MinUptimeHidServDirectoryV2 "
"option must be at least 0 seconds. Changing to 0.\n");
- tt_int_op(tdata->opt->MinUptimeHidServDirectoryV2, OP_EQ, 0);
+ tt_int_op(get_dirauth_options(tdata->opt)->MinUptimeHidServDirectoryV2,
+ OP_EQ, 0);
tor_free(msg);
done:
More information about the tor-commits
mailing list