mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 13:13:44 +01:00
make options.ExitNodes work
if your best choices happen to include any of your preferred exit nodes, you choose among just those preferred exit nodes. svn:r911
This commit is contained in:
parent
4d3d99fa0c
commit
78a7de300c
@ -247,7 +247,7 @@ static routerinfo_t *choose_good_exit_server(routerlist_t *dir)
|
||||
int best_support_idx = -1;
|
||||
int best_maybe_support_idx = -1;
|
||||
int n_best_support=0, n_best_maybe_support=0;
|
||||
smartlist_t *sl;
|
||||
smartlist_t *sl, *preferredexits;
|
||||
routerinfo_t *router;
|
||||
|
||||
get_connection_array(&carray, &n_connections);
|
||||
@ -335,15 +335,22 @@ static routerinfo_t *choose_good_exit_server(routerlist_t *dir)
|
||||
"pending connections, and %d that might support %d/%d.",
|
||||
n_best_support, best_support, n_pending_connections,
|
||||
n_best_maybe_support, best_maybe_support, n_pending_connections);
|
||||
|
||||
preferredexits = smartlist_create(MAX_ROUTERS_IN_DIR);
|
||||
add_nickname_list_to_smartlist(preferredexits,options.ExitNodes);
|
||||
|
||||
/* If any routers definitely support any pending connections, choose one
|
||||
* at random. */
|
||||
if (best_support > 0) {
|
||||
sl = smartlist_create(MAX_ROUTERS_IN_DIR);
|
||||
for(i = best_support_idx; i < dir->n_routers; i++)
|
||||
if(n_supported[i] == best_support)
|
||||
for (i = best_support_idx; i < dir->n_routers; i++)
|
||||
if (n_supported[i] == best_support)
|
||||
smartlist_add(sl, dir->routers[i]);
|
||||
|
||||
if (smartlist_overlap(sl,preferredexits))
|
||||
smartlist_intersect(sl,preferredexits);
|
||||
router = smartlist_choose(sl);
|
||||
smartlist_free(preferredexits);
|
||||
smartlist_free(sl);
|
||||
tor_free(n_supported); tor_free(n_maybe_supported);
|
||||
log_fn(LOG_DEBUG, "Chose exit server '%s'", router->nickname);
|
||||
@ -358,7 +365,10 @@ static routerinfo_t *choose_good_exit_server(routerlist_t *dir)
|
||||
if(n_maybe_supported[i] == best_maybe_support)
|
||||
smartlist_add(sl, dir->routers[i]);
|
||||
|
||||
if (smartlist_overlap(sl,preferredexits))
|
||||
smartlist_intersect(sl,preferredexits);
|
||||
router = smartlist_choose(sl);
|
||||
smartlist_free(preferredexits);
|
||||
smartlist_free(sl);
|
||||
tor_free(n_supported); tor_free(n_maybe_supported);
|
||||
log_fn(LOG_DEBUG, "Chose exit server '%s'", router->nickname);
|
||||
@ -372,7 +382,10 @@ static routerinfo_t *choose_good_exit_server(routerlist_t *dir)
|
||||
if(n_supported[i] != -1)
|
||||
smartlist_add(sl, dir->routers[i]);
|
||||
|
||||
if (smartlist_overlap(sl,preferredexits))
|
||||
smartlist_intersect(sl,preferredexits);
|
||||
router = smartlist_choose(sl);
|
||||
smartlist_free(preferredexits);
|
||||
smartlist_free(sl);
|
||||
if(router) {
|
||||
tor_free(n_supported); tor_free(n_maybe_supported);
|
||||
|
Loading…
Reference in New Issue
Block a user