aboutsummaryrefslogtreecommitdiff
path: root/src/feature/dirauth/dirauth_config.c
diff options
context:
space:
mode:
authorteor <teor@torproject.org>2019-10-29 17:57:04 +1000
committerteor <teor@torproject.org>2019-10-31 12:34:20 +1000
commit0a511778eb6f3ca00d0e3da99327cce2cf179830 (patch)
treef2cc7d1827a65f0b27b29b55bdcc938feb3328a0 /src/feature/dirauth/dirauth_config.c
parentd5ca56e2543fb988de34b10d1d868c2c2e96cd51 (diff)
downloadtor-0a511778eb6f3ca00d0e3da99327cce2cf179830.tar.gz
tor-0a511778eb6f3ca00d0e3da99327cce2cf179830.zip
config: Move bw & other configs into the dirauth module
This commit: * moves bandwidth checks into dirauth_config, and * moves some other minor checks into dirauth_config. The moved code is disabled when the dirauth module is disabled. (And some of the checks are re-ordered, so the order of some warnings may change.) Part of 32213.
Diffstat (limited to 'src/feature/dirauth/dirauth_config.c')
-rw-r--r--src/feature/dirauth/dirauth_config.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/feature/dirauth/dirauth_config.c b/src/feature/dirauth/dirauth_config.c
index 56a71e950d..6574edb540 100644
--- a/src/feature/dirauth/dirauth_config.c
+++ b/src/feature/dirauth/dirauth_config.c
@@ -61,6 +61,11 @@ options_validate_dirauth_mode(const or_options_t *old_options,
return -1;
if (options->AuthoritativeDir) {
+ /* confirm that our address isn't broken, so we can complain now */
+ uint32_t tmp;
+ if (resolve_my_address(LOG_WARN, options, &tmp, NULL, NULL) < 0)
+ REJECT("Failed to resolve/guess local address. See logs for details.");
+
if (!options->ContactInfo && !options->TestingTorNetwork)
REJECT("Authoritative directory servers must set ContactInfo");
if (!options->RecommendedClientVersions)
@@ -117,6 +122,46 @@ options_validate_dirauth_mode(const or_options_t *old_options,
REJECT("Running as authoritative directory, but ClientOnly also set.");
}
+ /* 31851: the tests expect us to validate these options, even when we are
+ * not in authority mode. */
+ if (options->MinUptimeHidServDirectoryV2 < 0) {
+ log_warn(LD_CONFIG, "MinUptimeHidServDirectoryV2 option must be at "
+ "least 0 seconds. Changing to 0.");
+ options->MinUptimeHidServDirectoryV2 = 0;
+ }
+
+ return 0;
+}
+
+/**
+ * Legacy validation/normalization function for the dirauth bandwidth options
+ * in options. Uses old_options as the previous options.
+ *
+ * Returns 0 on success, returns -1 and sets *msg to a newly allocated string
+ * on error.
+ */
+int
+options_validate_dirauth_bandwidth(const or_options_t *old_options,
+ or_options_t *options,
+ char **msg)
+{
+ (void)old_options;
+
+ if (BUG(!options))
+ return -1;
+
+ if (BUG(!msg))
+ return -1;
+
+ /* 31851: the tests expect us to validate these options, even when we are
+ * not in authority mode. */
+ if (ensure_bandwidth_cap(&options->AuthDirFastGuarantee,
+ "AuthDirFastGuarantee", msg) < 0)
+ return -1;
+ if (ensure_bandwidth_cap(&options->AuthDirGuardBWGuarantee,
+ "AuthDirGuardBWGuarantee", msg) < 0)
+ return -1;
+
return 0;
}