mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
Move MinUptimeHidServDirectoryV2 to dirauth module.
This commit is contained in:
parent
b1d029b9a1
commit
77dea66e19
@ -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"),
|
||||
|
@ -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? */
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user