[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] router_choose_random_node can take a smartlist of nodes to ...
- To: or-cvs@freehaven.net
- Subject: [or-cvs] router_choose_random_node can take a smartlist of nodes to ...
- From: arma@seul.org (Roger Dingledine)
- Date: Fri, 2 Apr 2004 17:30:41 -0500 (EST)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Fri, 02 Apr 2004 17:30:57 -0500
- Reply-to: or-dev@freehaven.net
- Sender: owner-or-cvs@freehaven.net
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
onion.c or.h routerlist.c
Log Message:
router_choose_random_node can take a smartlist of nodes to exclude
Index: onion.c
===================================================================
RCS file: /home/or/cvsroot/src/or/onion.c,v
retrieving revision 1.138
retrieving revision 1.139
diff -u -d -r1.138 -r1.139
--- onion.c 2 Apr 2004 22:23:15 -0000 1.138
+++ onion.c 2 Apr 2004 22:30:39 -0000 1.139
@@ -334,7 +334,7 @@
if(purpose == CIRCUIT_PURPOSE_C_GENERAL)
return choose_good_exit_server_general(dir);
else
- return router_choose_random_node(dir, options.RendNodes, options.RendExcludeNodes);
+ return router_choose_random_node(dir, options.RendNodes, options.RendExcludeNodes, NULL);
}
cpath_build_state_t *onion_new_cpath_build_state(uint8_t purpose,
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.280
retrieving revision 1.281
diff -u -d -r1.280 -r1.281
--- or.h 2 Apr 2004 22:23:15 -0000 1.280
+++ or.h 2 Apr 2004 22:30:39 -0000 1.281
@@ -975,7 +975,9 @@
/********************************* routerlist.c ***************************/
routerinfo_t *router_pick_directory_server(void);
-routerinfo_t *router_choose_random_node(routerlist_t *dir, char *preferred, char *excluded);
+routerinfo_t *router_choose_random_node(routerlist_t *dir,
+ char *preferred, char *excluded,
+ smartlist_t *excludedsmartlist);
routerinfo_t *router_get_by_addr_port(uint32_t addr, uint16_t port);
routerinfo_t *router_get_by_link_pk(crypto_pk_env_t *pk);
routerinfo_t *router_get_by_nickname(char *nickname);
Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- routerlist.c 2 Apr 2004 22:23:15 -0000 1.46
+++ routerlist.c 2 Apr 2004 22:30:39 -0000 1.47
@@ -233,7 +233,13 @@
}
}
-routerinfo_t *router_choose_random_node(routerlist_t *dir, char *preferred, char *excluded)
+/* Pick a random node from preferred if possible, else from all of dir.
+ * Never pick a node in excluded.
+ * If excludedsmartlist is defined, never pick a node in it either.
+ */
+routerinfo_t *router_choose_random_node(routerlist_t *dir,
+ char *preferred, char *excluded,
+ smartlist_t *excludedsmartlist)
{
smartlist_t *sl, *excludednodes;
routerinfo_t *choice;
@@ -245,12 +251,16 @@
sl = smartlist_create();
add_nickname_list_to_smartlist(sl,preferred);
smartlist_subtract(sl,excludednodes);
+ if(excludedsmartlist)
+ smartlist_subtract(sl,excludedsmartlist);
choice = smartlist_choose(sl);
smartlist_free(sl);
if(!choice) {
sl = smartlist_create();
router_add_running_routers_to_smartlist(sl);
smartlist_subtract(sl,excludednodes);
+ if(excludedsmartlist)
+ smartlist_subtract(sl,excludedsmartlist);
choice = smartlist_choose(sl);
smartlist_free(sl);
}