diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-04-27 12:45:07 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-04-27 12:45:07 -0400 |
commit | 346c2eb4e60299f69327b5e63e1e25aaf678f964 (patch) | |
tree | 110b6b0cecccecb62c6c0c917922e0f51dbce870 /src/or/entrynodes.c | |
parent | 8b58e1e323e362463906d2576b9d2b9e788c2f30 (diff) | |
parent | d00ed406e08942d6539281eb28e875939ee214e5 (diff) | |
download | tor-346c2eb4e60299f69327b5e63e1e25aaf678f964.tar.gz tor-346c2eb4e60299f69327b5e63e1e25aaf678f964.zip |
Merge branch 'bug25843_v2_squashed'
Diffstat (limited to 'src/or/entrynodes.c')
-rw-r--r-- | src/or/entrynodes.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c index 96e6ccaace..2c2bf99925 100644 --- a/src/or/entrynodes.c +++ b/src/or/entrynodes.c @@ -432,14 +432,15 @@ get_guard_confirmed_min_lifetime(void) STATIC int get_n_primary_guards(void) { - const int n = get_options()->NumEntryGuards; - const int n_dir = get_options()->NumDirectoryGuards; - if (n > 5) { - return MAX(n_dir, n + n / 2); - } else if (n >= 1) { - return MAX(n_dir, n * 2); + /* If the user has explicitly configured the number of primary guards, do + * what the user wishes to do */ + const int configured_primaries = get_options()->NumPrimaryGuards; + if (configured_primaries) { + return configured_primaries; } + /* otherwise check for consensus parameter and if that's not set either, just + * use the default value. */ return networkstatus_get_param(NULL, "guard-n-primary-guards", DFLT_N_PRIMARY_GUARDS, 1, INT32_MAX); @@ -454,6 +455,9 @@ get_n_primary_guards_to_use(guard_usage_t usage) int configured; const char *param_name; int param_default; + + /* If the user has explicitly configured the amount of guards, use + that. Otherwise, fall back to the default value. */ if (usage == GUARD_USAGE_DIRGUARD) { configured = get_options()->NumDirectoryGuards; param_name = "guard-n-primary-dir-guards-to-use"; |