[or-cvs] when building testing circuits, always use middle hops

Roger Dingledine arma at seul.org
Fri Apr 1 08:42:28 UTC 2005


Update of /home2/or/cvsroot/tor/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/tor/src/or

Modified Files:
	circuitbuild.c circuituse.c routerlist.c 
Log Message:
when building testing circuits, always use middle hops
running at least 0.0.9.7


Index: circuitbuild.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/circuitbuild.c,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -d -r1.100 -r1.101
--- circuitbuild.c	1 Apr 2005 06:23:21 -0000	1.100
+++ circuitbuild.c	1 Apr 2005 08:42:26 -0000	1.101
@@ -23,7 +23,8 @@
 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 @@
 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 @@
   }
 }
 
-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 @@
       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 @@
  * 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 @@
   } 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);

Index: circuituse.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/circuituse.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- circuituse.c	1 Apr 2005 07:25:18 -0000	1.63
+++ circuituse.c	1 Apr 2005 08:42:26 -0000	1.64
@@ -557,12 +557,14 @@
 /** 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

Index: routerlist.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.221
retrieving revision 1.222
diff -u -d -r1.221 -r1.222
--- routerlist.c	22 Mar 2005 00:42:38 -0000	1.221
+++ routerlist.c	1 Apr 2005 08:42:26 -0000	1.222
@@ -174,7 +174,7 @@
 
   /* 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;



More information about the tor-commits mailing list