when building testing circuits, always use middle hops

running at least 0.0.9.7


svn:r3966
This commit is contained in:
Roger Dingledine 2005-04-01 08:42:26 +00:00
parent 669f1947ed
commit e786e5dedb
3 changed files with 31 additions and 7 deletions

View File

@ -23,7 +23,8 @@ static int circuit_deliver_create_cell(circuit_t *circ, char *payload);
static int onion_pick_cpath_exit(circuit_t *circ, routerinfo_t *exit);
static crypt_path_t *onion_next_hop_in_cpath(crypt_path_t *cpath);
static int onion_next_router_in_cpath(circuit_t *circ, routerinfo_t **router);
static int onion_extend_cpath(crypt_path_t **head_ptr, cpath_build_state_t *state);
static int onion_extend_cpath(uint8_t purpose, crypt_path_t **head_ptr,
cpath_build_state_t *state);
static int count_acceptable_routers(smartlist_t *routers);
static int onion_append_hop(crypt_path_t **head_ptr, routerinfo_t *choice);
@ -234,7 +235,7 @@ static int
onion_populate_cpath(circuit_t *circ) {
int r;
again:
r = onion_extend_cpath(&circ->cpath, circ->build_state);
r = onion_extend_cpath(circ->purpose, &circ->cpath, circ->build_state);
// || !CIRCUIT_IS_ORIGIN(circ)) { // wtf? -rd
if (r < 0) {
log_fn(LOG_INFO,"Generating cpath hop failed.");
@ -1255,7 +1256,25 @@ void onion_append_to_cpath(crypt_path_t **head_ptr, crypt_path_t *new_hop)
}
}
static routerinfo_t *choose_good_middle_server(cpath_build_state_t *state,
/** Add to sl all routers with platform version less than cutoff. */
static void
excluded_add_obsolete(smartlist_t *sl, const char *cutoff) {
routerlist_t *rl;
int i;
routerinfo_t *router;
router_get_routerlist(&rl);
if (!rl) return;
for (i = 0; i < smartlist_len(rl->routers); ++i) { /* iterate over routers */
router = smartlist_get(rl->routers, i);
if (!tor_version_as_new_as(router->platform,cutoff))
smartlist_add(sl, router);
}
}
static routerinfo_t *choose_good_middle_server(uint8_t purpose,
cpath_build_state_t *state,
crypt_path_t *head,
int cur_len)
{
@ -1280,6 +1299,8 @@ static routerinfo_t *choose_good_middle_server(cpath_build_state_t *state,
routerlist_add_family(excluded, r);
}
}
if (purpose == CIRCUIT_PURPOSE_TESTING)
excluded_add_obsolete(excluded, "0.0.9.7");
choice = router_choose_random_node(NULL, get_options()->ExcludeNodes, excluded,
state->need_uptime, state->need_capacity,
get_options()->_AllowUnverified & ALLOW_UNVERIFIED_MIDDLE, 0);
@ -1362,7 +1383,8 @@ onion_next_router_in_cpath(circuit_t *circ, routerinfo_t **router) {
* based on <b>state</b>. Append the hop info to head_ptr.
*/
static int
onion_extend_cpath(crypt_path_t **head_ptr, cpath_build_state_t *state)
onion_extend_cpath(uint8_t purpose, crypt_path_t **head_ptr,
cpath_build_state_t *state)
{
int cur_len;
crypt_path_t *cpath;
@ -1397,7 +1419,7 @@ onion_extend_cpath(crypt_path_t **head_ptr, cpath_build_state_t *state)
} else if (cur_len == 0) { /* picking first node */
choice = choose_good_entry_server(state);
} else {
choice = choose_good_middle_server(state, *head_ptr, cur_len);
choice = choose_good_middle_server(purpose, state, *head_ptr, cur_len);
}
smartlist_free(excludednodes);

View File

@ -557,12 +557,14 @@ circuit_testing_opened(circuit_t *circ) {
/** A testing circuit has failed to build. Take whatever stats we want. */
static void
circuit_testing_failed(circuit_t *circ, int at_last_hop) {
#if 0
routerinfo_t *me = router_get_my_routerinfo();
if (!at_last_hop)
circuit_launch_by_router(CIRCUIT_PURPOSE_TESTING, me, 0, 1, 1);
else
log_fn(LOG_INFO,"Our testing circuit (to see if your ORPort is reachable) has failed. I'll try again later.");
#endif
log_fn(LOG_INFO,"Our testing circuit (to see if your ORPort is reachable) has failed. I'll try again later.");
}
/** The circuit <b>circ</b> has just become open. Take the next

View File

@ -174,7 +174,7 @@ router_pick_directory_server_impl(int requireothers, int fascistfirewall,
/* Find all the running dirservers we know about. */
sl = smartlist_create();
for (i=0;i< smartlist_len(routerlist->routers); i++) {
for (i=0;i < smartlist_len(routerlist->routers); i++) {
router = smartlist_get(routerlist->routers, i);
if (!router->is_running || !router->dir_port || !router->is_verified)
continue;