diff options
author | Roger Dingledine <arma@torproject.org> | 2003-12-13 07:01:46 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2003-12-13 07:01:46 +0000 |
commit | 9e6f4a30296815aab99393218c75b44d1aca25e4 (patch) | |
tree | 32079c3b86579348d8a92ebfe6f26bb9c75f0b15 /src/or/routerlist.c | |
parent | 5458ca39e8fd0ef582f3ed690fa589e44daf5c6b (diff) | |
download | tor-9e6f4a30296815aab99393218c75b44d1aca25e4.tar.gz tor-9e6f4a30296815aab99393218c75b44d1aca25e4.zip |
revamp circuit node selection to use smartlists:
* now we know for sure if an acceptable node is available; we
don't have to keep guessing and checking
* we try options.EntryNodes first for picking the first node
svn:r904
Diffstat (limited to 'src/or/routerlist.c')
-rw-r--r-- | src/or/routerlist.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 195c3cbb02..2967413ea3 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -129,23 +129,20 @@ routerinfo_t *router_pick_directory_server(void) { return dirserver; } -routerinfo_t *router_pick_randomly_from_running(void) { - int i; +void router_add_running_routers_to_smartlist(smartlist_t *sl) { routerinfo_t *router; - smartlist_t *sl; + int i; if(!routerlist) - return NULL; - - sl = smartlist_create(MAX_ROUTERS_IN_DIR); - for(i=0;i<routerlist->n_routers;i++) - if(routerlist->routers[i]->is_running) - smartlist_add(sl, routerlist->routers[i]); + return; - router = smartlist_choose(sl); - smartlist_free(sl); - log_fn(LOG_DEBUG, "Chose server '%s'", router ? router->nickname : "<none>"); - return router; + for(i=0;i<routerlist->n_routers;i++) { + router = routerlist->routers[i]; + if(router->is_running && + (!options.ORPort || + connection_twin_get_by_addr_port(router->addr, router->or_port) )) + smartlist_add(sl, router); + } } routerinfo_t *router_get_by_addr_port(uint32_t addr, uint16_t port) { |