aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2007-05-22 01:01:24 +0000
committerRoger Dingledine <arma@torproject.org>2007-05-22 01:01:24 +0000
commit6ede110c4de344ee4c51e730a054ff624ea1de75 (patch)
treec26f2cb52c824942f950613fc99fd216eaf81a42 /src
parent5741739a0ddb139b3e05d498590bde12706bb9ee (diff)
downloadtor-6ede110c4de344ee4c51e730a054ff624ea1de75.tar
tor-6ede110c4de344ee4c51e730a054ff624ea1de75.tar.gz
When choosing an entry guard for our circuit, avoid using guards
that are in the same family as the chosen exit -- not just guards that are exactly the chosen exit. (Reported by lodger.) svn:r10240
Diffstat (limited to 'src')
-rw-r--r--src/or/circuitbuild.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 24a8f0c72..fda3b85ec 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -2339,11 +2339,14 @@ choose_random_entry(cpath_build_state_t *state)
{
or_options_t *options = get_options();
smartlist_t *live_entry_guards = smartlist_create();
+ smartlist_t *exit_family = smartlist_create();
routerinfo_t *chosen_exit = build_state_get_exit_router(state);
routerinfo_t *r = NULL;
int need_uptime = state->need_uptime;
int need_capacity = state->need_capacity;
+ routerlist_add_family(exit_family, chosen_exit);
+
if (!entry_guards)
entry_guards = smartlist_create();
@@ -2360,7 +2363,7 @@ choose_random_entry(cpath_build_state_t *state)
SMARTLIST_FOREACH(entry_guards, entry_guard_t *, entry,
{
r = entry_is_live(entry, need_uptime, need_capacity, 0);
- if (r && r != chosen_exit) {
+ if (r && !smartlist_isin(exit_family, r)) {
smartlist_add(live_entry_guards, r);
if (smartlist_len(live_entry_guards) >= options->NumEntryGuards)
break; /* we have enough */
@@ -2397,6 +2400,7 @@ choose_random_entry(cpath_build_state_t *state)
r = smartlist_choose(live_entry_guards);
smartlist_free(live_entry_guards);
+ smartlist_free(exit_family);
return r;
}