aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2013-07-30 12:05:39 -0400
committerRoger Dingledine <arma@torproject.org>2013-07-30 12:05:39 -0400
commitff6bb13c02b3bb217ac8d48d5a20953f1b188d46 (patch)
tree68e34a3c84b36c68bdaa149b1c3eb47aac6f8f9f /src/or
parent8d0fb3a4347aa543d2aa27f177446888fbdae125 (diff)
downloadtor-ff6bb13c02b3bb217ac8d48d5a20953f1b188d46.tar.gz
tor-ff6bb13c02b3bb217ac8d48d5a20953f1b188d46.zip
NumDirectoryGuards now tracks NumEntryGuards by default
Now a user who changes only NumEntryGuards will get the behavior she expects. Fixes bug 9354; bugfix on 0.2.4.8-alpha.
Diffstat (limited to 'src/or')
-rw-r--r--src/or/config.c2
-rw-r--r--src/or/entrynodes.c17
-rw-r--r--src/or/or.h3
3 files changed, 16 insertions, 6 deletions
diff --git a/src/or/config.c b/src/or/config.c
index bf82643b91..72ceea395e 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -314,7 +314,7 @@ static config_var_t option_vars_[] = {
OBSOLETE("NoPublish"),
VAR("NodeFamily", LINELIST, NodeFamilies, NULL),
V(NumCPUs, UINT, "0"),
- V(NumDirectoryGuards, UINT, "3"),
+ V(NumDirectoryGuards, UINT, "0"),
V(NumEntryGuards, UINT, "3"),
V(ORListenAddress, LINELIST, NULL),
VPORT(ORPort, LINELIST, NULL),
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 7a1f67d16a..f1af75aefb 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -415,14 +415,24 @@ add_an_entry_guard(const node_t *chosen, int reset_status, int prepend,
return node;
}
+/** Choose how many entry guards or directory guards we'll use. If
+ * <b>for_directory</b> is true, we return how many directory guards to
+ * use; else we return how many entry guards to use. */
+static int
+decide_num_guards(const or_options_t *options, int for_directory)
+{
+ if (for_directory && options->NumDirectoryGuards != 0)
+ return options->NumDirectoryGuards;
+ return options->NumEntryGuards;
+}
+
/** If the use of entry guards is configured, choose more entry guards
* until we have enough in the list. */
static void
pick_entry_guards(const or_options_t *options, int for_directory)
{
int changed = 0;
- const int num_needed = for_directory ? options->NumDirectoryGuards :
- options->NumEntryGuards;
+ const int num_needed = decide_num_guards(options, for_directory);
tor_assert(entry_guards);
@@ -962,8 +972,7 @@ choose_random_entry_impl(cpath_build_state_t *state, int for_directory,
int need_capacity = state ? state->need_capacity : 0;
int preferred_min, consider_exit_family = 0;
int need_descriptor = !for_directory;
- const int num_needed = for_directory ? options->NumDirectoryGuards :
- options->NumEntryGuards;
+ const int num_needed = decide_num_guards(options, for_directory);
if (chosen_exit) {
nodelist_add_node_and_family(exit_family, chosen_exit);
diff --git a/src/or/or.h b/src/or/or.h
index 0b8d057aaf..3dc96b9a9d 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -3769,7 +3769,8 @@ typedef struct {
int NumEntryGuards; /**< How many entry guards do we try to establish? */
int UseEntryGuardsAsDirGuards; /** Boolean: Do we try to get directory info
* from a smallish number of fixed nodes? */
- int NumDirectoryGuards; /**< How many dir guards do we try to establish? */
+ int NumDirectoryGuards; /**< How many dir guards do we try to establish?
+ * If 0, use value from NumEntryGuards. */
int RephistTrackTime; /**< How many seconds do we keep rephist info? */
int FastFirstHopPK; /**< If Tor believes it is safe, should we save a third
* of our PK time by sending CREATE_FAST cells? */