mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-14 07:03:44 +01:00
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.
This commit is contained in:
parent
d5ca56e254
commit
0a511778eb
@ -3418,13 +3418,6 @@ options_validate_cb(const void *old_options_, void *options_, char **msg)
|
|||||||
if (options_init_logs(old_options, options, 1)<0)
|
if (options_init_logs(old_options, options, 1)<0)
|
||||||
REJECT("Failed to validate Log options. See logs for details.");
|
REJECT("Failed to validate Log options. See logs for details.");
|
||||||
|
|
||||||
if (authdir_mode(options)) {
|
|
||||||
/* 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.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* XXXX require that the only port not be DirPort? */
|
/* XXXX require that the only port not be DirPort? */
|
||||||
/* XXXX require that at least one port be listened-upon. */
|
/* XXXX require that at least one port be listened-upon. */
|
||||||
if (n_ports == 0 && !options->RendConfigLines)
|
if (n_ports == 0 && !options->RendConfigLines)
|
||||||
@ -3649,12 +3642,6 @@ options_validate_cb(const void *old_options_, void *options_, char **msg)
|
|||||||
if (options_validate_relay_padding(old_options, options, msg) < 0)
|
if (options_validate_relay_padding(old_options, options, msg) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (options->MinUptimeHidServDirectoryV2 < 0) {
|
|
||||||
log_warn(LD_CONFIG, "MinUptimeHidServDirectoryV2 option must be at "
|
|
||||||
"least 0 seconds. Changing to 0.");
|
|
||||||
options->MinUptimeHidServDirectoryV2 = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int min_rendpostperiod =
|
const int min_rendpostperiod =
|
||||||
options->TestingTorNetwork ?
|
options->TestingTorNetwork ?
|
||||||
MIN_REND_POST_PERIOD_TESTING : MIN_REND_POST_PERIOD;
|
MIN_REND_POST_PERIOD_TESTING : MIN_REND_POST_PERIOD;
|
||||||
@ -3833,16 +3820,11 @@ options_validate_cb(const void *old_options_, void *options_, char **msg)
|
|||||||
if (ensure_bandwidth_cap(&options->BandwidthBurst,
|
if (ensure_bandwidth_cap(&options->BandwidthBurst,
|
||||||
"BandwidthBurst", msg) < 0)
|
"BandwidthBurst", msg) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (ensure_bandwidth_cap(&options->AuthDirFastGuarantee,
|
|
||||||
"AuthDirFastGuarantee", msg) < 0)
|
|
||||||
return -1;
|
|
||||||
if (ensure_bandwidth_cap(&options->AuthDirGuardBWGuarantee,
|
|
||||||
"AuthDirGuardBWGuarantee", msg) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
|
|
||||||
if (options_validate_relay_bandwidth(old_options, options, msg) < 0)
|
if (options_validate_relay_bandwidth(old_options, options, msg) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
if (options_validate_dirauth_bandwidth(old_options, options, msg) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (options->BandwidthRate > options->BandwidthBurst)
|
if (options->BandwidthRate > options->BandwidthBurst)
|
||||||
REJECT("BandwidthBurst must be at least equal to BandwidthRate.");
|
REJECT("BandwidthBurst must be at least equal to BandwidthRate.");
|
||||||
|
@ -61,6 +61,11 @@ options_validate_dirauth_mode(const or_options_t *old_options,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (options->AuthoritativeDir) {
|
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)
|
if (!options->ContactInfo && !options->TestingTorNetwork)
|
||||||
REJECT("Authoritative directory servers must set ContactInfo");
|
REJECT("Authoritative directory servers must set ContactInfo");
|
||||||
if (!options->RecommendedClientVersions)
|
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.");
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,10 @@ int options_validate_dirauth_mode(const or_options_t *old_options,
|
|||||||
or_options_t *options,
|
or_options_t *options,
|
||||||
char **msg);
|
char **msg);
|
||||||
|
|
||||||
|
int options_validate_dirauth_bandwidth(const or_options_t *old_options,
|
||||||
|
or_options_t *options,
|
||||||
|
char **msg);
|
||||||
|
|
||||||
int options_validate_dirauth_schedule(const or_options_t *old_options,
|
int options_validate_dirauth_schedule(const or_options_t *old_options,
|
||||||
or_options_t *options,
|
or_options_t *options,
|
||||||
char **msg);
|
char **msg);
|
||||||
@ -56,6 +60,9 @@ options_validate_dirauth_mode(const or_options_t *old_options,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define options_validate_dirauth_bandwidth(old_options, options, msg) \
|
||||||
|
(((void)(old_options)),((void)(options)),((void)(msg)),0)
|
||||||
|
|
||||||
#define options_validate_dirauth_schedule(old_options, options, msg) \
|
#define options_validate_dirauth_schedule(old_options, options, msg) \
|
||||||
(((void)(old_options)),((void)(options)),((void)(msg)),0)
|
(((void)(old_options)),((void)(options)),((void)(msg)),0)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user