mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
relay: Simplify some relay_config code
Part of 32213.
This commit is contained in:
parent
d3c8486724
commit
4d9a5c77f8
@ -242,6 +242,7 @@ parse_ports_relay(or_options_t *options,
|
||||
{
|
||||
int retval = -1;
|
||||
smartlist_t *ports = smartlist_new();
|
||||
int n_low_ports = 0;
|
||||
|
||||
if (BUG(!options))
|
||||
goto err;
|
||||
@ -255,7 +256,11 @@ parse_ports_relay(or_options_t *options,
|
||||
if (BUG(!have_low_ports_out))
|
||||
goto err;
|
||||
|
||||
if (! options->ClientOnly) {
|
||||
if (options->ClientOnly) {
|
||||
retval = 0;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (parse_port_config(ports,
|
||||
options->ORPort_lines,
|
||||
"OR", CONN_TYPE_OR_LISTENER,
|
||||
@ -280,15 +285,11 @@ parse_ports_relay(or_options_t *options,
|
||||
*msg = tor_strdup("Invalid DirPort configuration");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
int n_low_ports = 0;
|
||||
if (check_server_ports(ports, options, &n_low_ports) < 0) {
|
||||
*msg = tor_strdup("Misconfigured server ports");
|
||||
goto err;
|
||||
}
|
||||
if (*have_low_ports_out < 0)
|
||||
*have_low_ports_out = (n_low_ports > 0);
|
||||
|
||||
smartlist_add_all(ports_out, ports);
|
||||
smartlist_free(ports);
|
||||
@ -296,6 +297,8 @@ parse_ports_relay(or_options_t *options,
|
||||
retval = 0;
|
||||
|
||||
err:
|
||||
if (*have_low_ports_out < 0)
|
||||
*have_low_ports_out = (n_low_ports > 0);
|
||||
if (ports) {
|
||||
SMARTLIST_FOREACH(ports, port_cfg_t *, p, port_cfg_free(p));
|
||||
smartlist_free(ports);
|
||||
@ -314,6 +317,9 @@ update_port_set_relay(or_options_t *options,
|
||||
if (BUG(!ports))
|
||||
return;
|
||||
|
||||
if (options->ClientOnly)
|
||||
return;
|
||||
|
||||
/* Update the relay *Port_set options. The !! here is to force a boolean
|
||||
* out of an integer. */
|
||||
options->ORPort_set =
|
||||
@ -343,12 +349,14 @@ options_validate_relay_os(const or_options_t *old_options,
|
||||
if (BUG(!msg))
|
||||
return -1;
|
||||
|
||||
if (!server_mode(options))
|
||||
return 0;
|
||||
|
||||
const char *uname = get_uname();
|
||||
|
||||
if (server_mode(options) &&
|
||||
(!strcmpstart(uname, "Windows 95") ||
|
||||
if (!strcmpstart(uname, "Windows 95") ||
|
||||
!strcmpstart(uname, "Windows 98") ||
|
||||
!strcmpstart(uname, "Windows Me"))) {
|
||||
!strcmpstart(uname, "Windows Me")) {
|
||||
log_warn(LD_CONFIG, "Tor is running as a server, but you are "
|
||||
"running %s; this probably won't work. See "
|
||||
"https://www.torproject.org/docs/faq.html#BestOSForRelay "
|
||||
@ -572,19 +580,22 @@ options_validate_relay_padding(const or_options_t *old_options,
|
||||
if (BUG(!msg))
|
||||
return -1;
|
||||
|
||||
if (server_mode(options) && options->ConnectionPadding != -1) {
|
||||
if (!server_mode(options))
|
||||
return 0;
|
||||
|
||||
if (options->ConnectionPadding != -1) {
|
||||
REJECT("Relays must use 'auto' for the ConnectionPadding setting.");
|
||||
}
|
||||
|
||||
if (server_mode(options) && options->ReducedConnectionPadding != 0) {
|
||||
if (options->ReducedConnectionPadding != 0) {
|
||||
REJECT("Relays cannot set ReducedConnectionPadding. ");
|
||||
}
|
||||
|
||||
if (server_mode(options) && options->CircuitPadding == 0) {
|
||||
if (options->CircuitPadding == 0) {
|
||||
REJECT("Relays cannot set CircuitPadding to 0. ");
|
||||
}
|
||||
|
||||
if (server_mode(options) && options->ReducedCircuitPadding == 1) {
|
||||
if (options->ReducedCircuitPadding == 1) {
|
||||
REJECT("Relays cannot set ReducedCircuitPadding. ");
|
||||
}
|
||||
|
||||
@ -1408,6 +1419,9 @@ options_act_relay_dir(const or_options_t *old_options)
|
||||
|
||||
const or_options_t *options = get_options();
|
||||
|
||||
if (!public_server_mode(options))
|
||||
return 0;
|
||||
|
||||
/* Load the webpage we're going to serve every time someone asks for '/' on
|
||||
our DirPort. */
|
||||
tor_free(global_dirfrontpagecontents);
|
||||
|
Loading…
Reference in New Issue
Block a user