summaryrefslogtreecommitdiff
path: root/src/or/config.c
diff options
context:
space:
mode:
authorteor <teor2345@gmail.com>2016-09-06 16:22:07 +1000
committerNick Mathewson <nickm@torproject.org>2016-09-13 10:13:56 -0400
commit41f96078c23e3ef1c39a853841332cac3e133a94 (patch)
tree199e75ee2649d7421ee855e31ef2252c74ee57f1 /src/or/config.c
parent0285f4f34d72b2b77f36fd55fa46216f6b54efc4 (diff)
downloadtor-41f96078c23e3ef1c39a853841332cac3e133a94.tar.gz
tor-41f96078c23e3ef1c39a853841332cac3e133a94.zip
Refactor UseEntryNodes so the original configured value is preserved
Parse the value to UseEntryNodes_option, then set UseEntryNodes before validating options. This way, Authorities, Tor2web, and Single Onion Services don't write spurious "UseEntryNodes 0" lines to their configs. Document the fact that these tor configurations ignore UseEntryNodes in the manual page. Also reorder options validation so we modify UseEntryNodes first, then check its value against EntryNodes. And silence a warning about disabled UseEntryNodes for hidden services when we're actually in non-anonymous single onion service mode.
Diffstat (limited to 'src/or/config.c')
-rw-r--r--src/or/config.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/or/config.c b/src/or/config.c
index 36b2062271..48f1ab98e7 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -437,7 +437,7 @@ static config_var_t option_vars_[] = {
OBSOLETE("TunnelDirConns"),
V(UpdateBridgesFromAuthority, BOOL, "0"),
V(UseBridges, BOOL, "0"),
- V(UseEntryGuards, BOOL, "1"),
+ VAR("UseEntryGuards", BOOL, UseEntryGuards_option, "1"),
V(UseEntryGuardsAsDirGuards, BOOL, "1"),
V(UseGuardFraction, AUTOBOOL, "auto"),
V(UseMicrodescriptors, AUTOBOOL, "auto"),
@@ -2926,6 +2926,12 @@ options_validate(or_options_t *old_options, or_options_t *options,
tor_assert(msg);
*msg = NULL;
+ /* Set UseEntryGuards from the configured value, before we check it below.
+ * We change UseEntryGuards whenn it's incompatible with other options,
+ * but leave UseEntryGuards_option with the original value.
+ * Always use the value of UseEntryGuards, not UseEntryGuards_option. */
+ options->UseEntryGuards = options->UseEntryGuards_option;
+
warn_about_relative_paths(options);
if (server_mode(options) &&
@@ -3301,10 +3307,6 @@ options_validate(or_options_t *old_options, or_options_t *options,
if (options->UseBridges && options->EntryNodes)
REJECT("You cannot set both UseBridges and EntryNodes.");
- if (options->EntryNodes && !options->UseEntryGuards) {
- REJECT("If EntryNodes is set, UseEntryGuards must be enabled.");
- }
-
options->MaxMemInQueues =
compute_real_max_mem_in_queues(options->MaxMemInQueues_raw,
server_mode(options));
@@ -3419,8 +3421,13 @@ options_validate(or_options_t *old_options, or_options_t *options,
REJECT("Tor2webRendezvousPoints cannot be set without Tor2webMode.");
}
+ if (options->EntryNodes && !options->UseEntryGuards) {
+ REJECT("If EntryNodes is set, UseEntryGuards must be enabled.");
+ }
+
if (!(options->UseEntryGuards) &&
- (options->RendConfigLines != NULL)) {
+ (options->RendConfigLines != NULL) &&
+ !rend_service_non_anonymous_mode_enabled(options)) {
log_warn(LD_CONFIG,
"UseEntryGuards is disabled, but you have configured one or more "
"hidden services on this Tor instance. Your hidden services "