diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-12-11 13:05:35 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-12-25 23:14:43 -0500 |
commit | 0f9dfef9d636b269acad75f31e4cd278a1f246e9 (patch) | |
tree | ff024e698e6b64a7aac14e82f4de470fa5a4cbde /src/or/entrynodes.c | |
parent | 0c4210fb65d1fe45cbd39ea078be1b09c0f52fc9 (diff) | |
download | tor-0f9dfef9d636b269acad75f31e4cd278a1f246e9.tar tor-0f9dfef9d636b269acad75f31e4cd278a1f246e9.tar.gz |
Add configuration options for directory guards
In addition to all the other ways to make directory gurads not go,
you can now set UseEntryGuardsAsDirGuards to 0.
Diffstat (limited to 'src/or/entrynodes.c')
-rw-r--r-- | src/or/entrynodes.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c index a87209199..eb79938fc 100644 --- a/src/or/entrynodes.c +++ b/src/or/entrynodes.c @@ -400,10 +400,12 @@ 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; tor_assert(entry_guards); - while (num_live_entry_guards(for_directory) < options->NumEntryGuards) { + while (num_live_entry_guards(for_directory) < num_needed) { if (!add_an_entry_guard(NULL, 0, 0, for_directory)) break; changed = 1; @@ -861,6 +863,8 @@ 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; /* Checking dirinfo_type isn't required yet, since we only choose directory guards that can support microdescs, routerinfos, and networkstatuses, AND @@ -880,7 +884,7 @@ choose_random_entry_impl(cpath_build_state_t *state, int for_directory, entry_guards_set_from_config(options); if (!entry_list_is_constrained(options) && - smartlist_len(entry_guards) < options->NumEntryGuards) + smartlist_len(entry_guards) < num_needed) pick_entry_guards(options, for_directory); retry: @@ -923,7 +927,7 @@ choose_random_entry_impl(cpath_build_state_t *state, int for_directory, * guard list without needing to. */ goto choose_and_finish; } - if (smartlist_len(live_entry_guards) >= options->NumEntryGuards) + if (smartlist_len(live_entry_guards) >= num_needed) goto choose_and_finish; /* we have enough */ } SMARTLIST_FOREACH_END(entry); |