diff options
author | teor <teor@torproject.org> | 2019-10-30 13:55:49 +1000 |
---|---|---|
committer | teor <teor@torproject.org> | 2019-10-31 12:34:20 +1000 |
commit | 6d03c0566568f4a56efb4aea2f32bcd86c090a22 (patch) | |
tree | f56289ce7fd6af5e7c786132ea795a66375f1540 /src/feature | |
parent | 0a511778eb6f3ca00d0e3da99327cce2cf179830 (diff) | |
download | tor-6d03c0566568f4a56efb4aea2f32bcd86c090a22.tar.gz tor-6d03c0566568f4a56efb4aea2f32bcd86c090a22.zip |
config: Move server transport actions into the relay module
This commit:
* moves server transport config checks into transport_config.c,
* adds thin wrappers to make the moved code compile.
No functional changes: the moved code is still enabled,
even if the relay module is disabled. (Some of the checks
are re-ordered, so the order of some warnings may change.)
Part of 32213.
Diffstat (limited to 'src/feature')
-rw-r--r-- | src/feature/relay/transport_config.c | 57 | ||||
-rw-r--r-- | src/feature/relay/transport_config.h | 2 |
2 files changed, 59 insertions, 0 deletions
diff --git a/src/feature/relay/transport_config.c b/src/feature/relay/transport_config.c index b323f4299e..4ce00ec6c1 100644 --- a/src/feature/relay/transport_config.c +++ b/src/feature/relay/transport_config.c @@ -245,3 +245,60 @@ options_validate_server_transport(const or_options_t *old_options, return 0; } + +/** Fetch the active option list, and take server pluggable transport actions + * based on it. All of the things we do should survive being done repeatedly. + * If present, <b>old_options</b> contains the previous value of the options. + * + * Return 0 if all goes well, return -1 if it's time to die. + * + * Note: We haven't moved all the "act on new configuration" logic + * into the options_act* functions yet. Some is still in do_hup() and other + * places. + */ +int +options_act_server_transport(const or_options_t *old_options) +{ + (void)old_options; + + config_line_t *cl; + const or_options_t *options = get_options(); + int running_tor = options->command == CMD_RUN_TOR; + + /* If we are a bridge with a pluggable transport proxy but no + Extended ORPort, inform the user that they are missing out. */ + if (server_mode(options) && options->ServerTransportPlugin && + !options->ExtORPort_lines) { + log_notice(LD_CONFIG, "We use pluggable transports but the Extended " + "ORPort is disabled. Tor and your pluggable transports proxy " + "communicate with each other via the Extended ORPort so it " + "is suggested you enable it: it will also allow your Bridge " + "to collect statistics about its clients that use pluggable " + "transports. Please enable it using the ExtORPort torrc option " + "(e.g. set 'ExtORPort auto')."); + } + + /* If we have an ExtORPort, initialize its auth cookie. */ + if (running_tor && + init_ext_or_cookie_authentication(!!options->ExtORPort_lines) < 0) { + log_warn(LD_CONFIG,"Error creating Extended ORPort cookie file."); + return -1; + } + + if (!options->DisableNetwork) { + if (options->ServerTransportPlugin && server_mode(options)) { + for (cl = options->ServerTransportPlugin; cl; cl = cl->next) { + if (parse_transport_line(options, cl->value, 0, 1) < 0) { + // LCOV_EXCL_START + log_warn(LD_BUG, + "Previously validated ServerTransportPlugin line " + "could not be added!"); + return -1; + // LCOV_EXCL_STOP + } + } + } + } + + return 0; +} diff --git a/src/feature/relay/transport_config.h b/src/feature/relay/transport_config.h index 6ef1bc4020..d3ecc93388 100644 --- a/src/feature/relay/transport_config.h +++ b/src/feature/relay/transport_config.h @@ -24,4 +24,6 @@ int options_validate_server_transport(const or_options_t *old_options, or_options_t *options, char **msg); +int options_act_server_transport(const or_options_t *old_options); + #endif /* !defined(TOR_FEATURE_RELAY_TRANSPORT_CONFIG_H) */ |