diff options
author | Roger Dingledine <arma@torproject.org> | 2003-12-13 23:32:57 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2003-12-13 23:32:57 +0000 |
commit | 78a7de300c000bdc7cccd9187721e0d4eb18423a (patch) | |
tree | 1d9080b64f29f767acca1c832d344a8358e39443 /src | |
parent | 4d3d99fa0c5215bbaec94ba51424cdcedda3417a (diff) | |
download | tor-78a7de300c000bdc7cccd9187721e0d4eb18423a.tar.gz tor-78a7de300c000bdc7cccd9187721e0d4eb18423a.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/or/onion.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/or/onion.c b/src/or/onion.c index f1d8548eb8..aba8cd6de5 100644 --- a/src/or/onion.c +++ b/src/or/onion.c @@ -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); |