aboutsummaryrefslogtreecommitdiff
path: root/src/or/circuitbuild.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2006-06-13 10:25:22 +0000
committerRoger Dingledine <arma@torproject.org>2006-06-13 10:25:22 +0000
commit23e2c6a7ddec2821d85443900265546ee7b373da (patch)
tree0c264a93a324fbaa81c889c22cd5286eb134fc89 /src/or/circuitbuild.c
parent31b51849b50904e2206f59832bd86217c662dbd8 (diff)
downloadtor-23e2c6a7ddec2821d85443900265546ee7b373da.tar
tor-23e2c6a7ddec2821d85443900265546ee7b373da.tar.gz
first cut at a workaround for the reachability bug: explicitly find a
server running the right version, if we can, and ask for that one. svn:r6616
Diffstat (limited to 'src/or/circuitbuild.c')
-rw-r--r--src/or/circuitbuild.c48
1 files changed, 46 insertions, 2 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index d38de14bb..f557c5258 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -1457,6 +1457,46 @@ onion_append_to_cpath(crypt_path_t **head_ptr, crypt_path_t *new_hop)
}
}
+/** Pick a random server digest that's running a Tor version that
+ * doesn't have the reachability bug. These are versions 0.1.1.22+
+ * and 0.1.2.1-alpha+.
+ *
+ * We only return one, so this doesn't become stupid when the
+ * whole network has upgraded. */
+static char *
+compute_preferred_testing_list(const char *answer)
+{
+ smartlist_t *choices;
+ routerlist_t *rl = router_get_routerlist();
+ routerinfo_t *router;
+ char *s;
+
+ if (answer) /* they have one in mind -- easy */
+ return tor_strdup(answer);
+
+ choices = smartlist_create();
+ /* now count up our choices */
+ SMARTLIST_FOREACH(rl->routers, routerinfo_t *, r,
+ if (r->is_running && r->is_valid &&
+ ((tor_version_as_new_as(r->platform,"0.1.1.21-cvs") &&
+ !tor_version_as_new_as(r->platform,"0.1.2.0-alpha-cvs")) ||
+ tor_version_as_new_as(r->platform,"0.1.2.1-alpha")))
+ smartlist_add(choices, r));
+ router = smartlist_choose(choices);
+ smartlist_free(choices);
+ if (!router) {
+ log_info(LD_CIRC, "Looking for middle server that doesn't have the "
+ "reachability bug, but didn't find one. Oh well.");
+ return NULL;
+ }
+ log_info(LD_CIRC, "Looking for middle server that doesn't have the "
+ "reachability bug, and chose '%s'. Great.", router->nickname);
+ s = tor_malloc(HEX_DIGEST_LEN+1);
+ base16_encode(s, HEX_DIGEST_LEN+1,
+ router->cache_info.identity_digest, DIGEST_LEN);
+ return s;
+}
+
/** A helper function used by onion_extend_cpath(). Use <b>purpose</b>
* and <b>state</b> and the cpath <b>head</b> (currently populated only
* to length <b>cur_len</b> to decide a suitable middle hop for a
@@ -1474,6 +1514,7 @@ choose_good_middle_server(uint8_t purpose,
crypt_path_t *cpath;
smartlist_t *excluded;
or_options_t *options = get_options();
+ char *preferred = NULL;
tor_assert(_CIRCUIT_PURPOSE_MIN <= purpose &&
purpose <= _CIRCUIT_PURPOSE_MAX);
@@ -1493,11 +1534,14 @@ choose_good_middle_server(uint8_t purpose,
routerlist_add_family(excluded, r);
}
}
- choice = router_choose_random_node(
- purpose == CIRCUIT_PURPOSE_TESTING ? options->TestVia : NULL,
+ if (purpose == CIRCUIT_PURPOSE_TESTING)
+ preferred = compute_preferred_testing_list(options->TestVia);
+ choice = router_choose_random_node(preferred,
options->ExcludeNodes, excluded,
state->need_uptime, state->need_capacity, 0,
options->_AllowInvalid & ALLOW_INVALID_MIDDLE, 0);
+ if (preferred)
+ tor_free(preferred);
smartlist_free(excluded);
return choice;
}