From: Roger Dingledine Date: Wed, 23 Jul 2014 19:28:40 +0000 (-0400) Subject: add a NumDirectoryGuards consensus param too X-Git-Tag: tor-0.2.4.23~4^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9fc276a1c7f94d1e0a48e00a358536027a9a7820;p=thirdparty%2Ftor.git add a NumDirectoryGuards consensus param too --- diff --git a/changes/ticket12688 b/changes/ticket12688 index d8e56c1537..88228e5506 100644 --- a/changes/ticket12688 +++ b/changes/ticket12688 @@ -1,5 +1,6 @@ Major features: - - Make the number of entry guards (and thus, by default, directory - guards too) configurable via a new NumEntryGuards consensus + - Make the number of entry guards configurable via a new + NumEntryGuards consensus parameter, and the number of directory + guards configurable via a new NumDirectoryGuards consensus parameter. Implements ticket 12688. diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c index abd10e385e..484b88dbf8 100644 --- a/src/or/entrynodes.c +++ b/src/or/entrynodes.c @@ -433,10 +433,18 @@ add_an_entry_guard(const node_t *chosen, int reset_status, int prepend, static int decide_num_guards(const or_options_t *options, int for_directory) { - if (for_directory && options->NumDirectoryGuards != 0) - return options->NumDirectoryGuards; + if (for_directory) { + int answer; + if (options->NumDirectoryGuards != 0) + return options->NumDirectoryGuards; + answer = networkstatus_get_param(NULL, "NumDirectoryGuards", 0, 0, 10); + if (answer) /* non-zero means use the consensus value */ + return answer; + } + if (options->NumEntryGuards) return options->NumEntryGuards; + /* Use the value from the consensus, or 3 if no guidance. */ return networkstatus_get_param(NULL, "NumEntryGuards", 3, 1, 10); }