aboutsummaryrefslogtreecommitdiff
path: root/src/or/entrynodes.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2014-07-24 16:23:26 -0400
committerRoger Dingledine <arma@torproject.org>2014-07-24 16:23:26 -0400
commitbc9866e13ff140b237b0560a784bb72bff67a8e3 (patch)
tree962abd71251435b1174b8a33ab7fe532fffe9fa0 /src/or/entrynodes.c
parentdfe80c966d5136bc4f3287f4f762384ecc4df0c5 (diff)
parenta4c641cce91acb673f81db2b6093fde425039eaf (diff)
downloadtor-bc9866e13ff140b237b0560a784bb72bff67a8e3.tar.gz
tor-bc9866e13ff140b237b0560a784bb72bff67a8e3.zip
Merge branch 'maint-0.2.5'
Diffstat (limited to 'src/or/entrynodes.c')
-rw-r--r--src/or/entrynodes.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 4d09195796..365b9274ec 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -453,9 +453,20 @@ 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;
- return options->NumEntryGuards;
+ 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);
}
/** If the use of entry guards is configured, choose more entry guards
@@ -856,6 +867,7 @@ entry_guards_set_from_config(const or_options_t *options)
{
smartlist_t *entry_nodes, *worse_entry_nodes, *entry_fps;
smartlist_t *old_entry_guards_on_list, *old_entry_guards_not_on_list;
+ const int numentryguards = decide_num_guards(options, 0);
tor_assert(entry_guards);
should_add_entry_nodes = 0;
@@ -924,7 +936,7 @@ entry_guards_set_from_config(const or_options_t *options)
/* Next, the rest of EntryNodes */
SMARTLIST_FOREACH_BEGIN(entry_nodes, const node_t *, node) {
add_an_entry_guard(node, 0, 0, 1, 0);
- if (smartlist_len(entry_guards) > options->NumEntryGuards * 10)
+ if (smartlist_len(entry_guards) > numentryguards * 10)
break;
} SMARTLIST_FOREACH_END(node);
log_notice(LD_GENERAL, "%d entries in guards", smartlist_len(entry_guards));