[or-cvs] tolerate old 0.0.7 clients that demand a certain ip:port fo...

Roger Dingledine arma at seul.org
Wed Aug 18 11:20:17 UTC 2004


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

Modified Files:
	circuitbuild.c command.c or.h routerlist.c 
Log Message:
tolerate old 0.0.7 clients that demand a certain ip:port for a router
even though it's moved on to another one.

also reduce some log verbosity.


Index: circuitbuild.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuitbuild.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- circuitbuild.c	18 Aug 2004 10:32:50 -0000	1.30
+++ circuitbuild.c	18 Aug 2004 11:20:15 -0000	1.31
@@ -435,6 +435,7 @@
   int old_format;
   char *onionskin;
   char *id_digest=NULL;
+  routerinfo_t *router;
 
   if(circ->n_conn) {
     log_fn(LOG_WARN,"n_conn already set. Bug/attack. Closing.");
@@ -458,6 +459,11 @@
   if (old_format) {
     n_conn = connection_exact_get_by_addr_port(circ->n_addr,circ->n_port);
     onionskin = cell->payload+RELAY_HEADER_SIZE+4+2;
+    if(!n_conn) { /* hunt around for it a bit before giving up */
+      router = router_get_by_addr_port(circ->n_addr, circ->n_port);
+      if(router)
+        n_conn = connection_get_by_identity_digest(router->identity_digest, CONN_TYPE_OR);
+    }
   } else {
     onionskin = cell->payload+RELAY_HEADER_SIZE+4+2;
     id_digest = cell->payload+RELAY_HEADER_SIZE+4+2+ONIONSKIN_CHALLENGE_LEN;
@@ -468,7 +474,6 @@
      /* Note that this will close circuits where the onion has the same
      * router twice in a row in the path. I think that's ok.
      */
-    routerinfo_t *router;
     struct in_addr in;
     in.s_addr = htonl(circ->n_addr);
     log_fn(LOG_INFO,"Next router (%s:%d) not connected. Connecting.",
@@ -803,7 +808,7 @@
   routerinfo_t *router;
 
   preferredentries = smartlist_create();
-  add_nickname_list_to_smartlist(preferredentries,options.EntryNodes);
+  add_nickname_list_to_smartlist(preferredentries,options.EntryNodes,1);
 
   get_connection_array(&carray, &n_connections);
 
@@ -892,10 +897,10 @@
          n_best_support, best_support, n_pending_connections);
 
   preferredexits = smartlist_create();
-  add_nickname_list_to_smartlist(preferredexits,options.ExitNodes);
+  add_nickname_list_to_smartlist(preferredexits,options.ExitNodes,1);
 
   excludedexits = smartlist_create();
-  add_nickname_list_to_smartlist(excludedexits,options.ExcludeNodes);
+  add_nickname_list_to_smartlist(excludedexits,options.ExcludeNodes,0);
 
   sl = smartlist_create();
 
@@ -1177,7 +1182,7 @@
          state->desired_path_len);
 
   excludednodes = smartlist_create();
-  add_nickname_list_to_smartlist(excludednodes,options.ExcludeNodes);
+  add_nickname_list_to_smartlist(excludednodes,options.ExcludeNodes,0);
 
   if(cur_len == state->desired_path_len - 1) { /* Picking last node */
     choice = router_get_by_digest(state->chosen_exit_digest);

Index: command.c
===================================================================
RCS file: /home/or/cvsroot/src/or/command.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- command.c	20 Jul 2004 23:31:00 -0000	1.67
+++ command.c	18 Aug 2004 11:20:15 -0000	1.68
@@ -48,7 +48,7 @@
   time_passed = tv_udiff(&start, &end) ;
 
   if (time_passed > 10000) { /* more than 10ms */
-    log_fn(LOG_INFO,"That call just took %ld ms.",time_passed/1000);
+    log_fn(LOG_DEBUG,"That call just took %ld ms.",time_passed/1000);
   }
   *time += time_passed;
 }

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.413
retrieving revision 1.414
diff -u -d -r1.413 -r1.414
--- or.h	18 Aug 2004 10:32:50 -0000	1.413
+++ or.h	18 Aug 2004 11:20:15 -0000	1.414
@@ -1394,7 +1394,7 @@
 routerinfo_t *router_pick_directory_server(int requireauth, int requireothers);
 int all_directory_servers_down(void);
 struct smartlist_t;
-void add_nickname_list_to_smartlist(struct smartlist_t *sl, const char *list);
+void add_nickname_list_to_smartlist(struct smartlist_t *sl, const char *list, int warn_if_down);
 routerinfo_t *routerlist_find_my_routerinfo(void);
 int router_nickname_matches(routerinfo_t *router, const char *nickname);
 routerinfo_t *routerlist_sl_choose_by_bandwidth(smartlist_t *sl);

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.130
retrieving revision 1.131
diff -u -d -r1.130 -r1.131
--- routerlist.c	18 Aug 2004 10:32:50 -0000	1.130
+++ routerlist.c	18 Aug 2004 11:20:15 -0000	1.131
@@ -152,7 +152,9 @@
  * nicknames in <b>list</b> name routers in our routerlist that are
  * currently running.  Add the routerinfos for those routers to <b>sl</b>.
  */
-void add_nickname_list_to_smartlist(smartlist_t *sl, const char *list) {
+void
+add_nickname_list_to_smartlist(smartlist_t *sl, const char *list, int warn_if_down)
+{
   const char *start,*end;
   char nick[MAX_HEX_NICKNAME_LEN+1];
   routerinfo_t *router;
@@ -177,7 +179,8 @@
       if (router->is_running)
         smartlist_add(sl,router);
       else
-        log_fn(LOG_WARN,"Nickname list includes '%s' which is known but down.",nick);
+        log_fn(warn_if_down ? LOG_WARN : LOG_DEBUG,
+               "Nickname list includes '%s' which is known but down.",nick);
     } else
       log_fn(has_fetched_directory ? LOG_WARN : LOG_INFO,
              "Nickname list includes '%s' which isn't a known router.",nick);
@@ -284,7 +287,7 @@
   SMARTLIST_FOREACH(bandwidths, uint32_t*, p, tor_free(p));
   smartlist_free(bandwidths);
   router = smartlist_get(sl, i);
-  log_fn(LOG_INFO,"Picked %s.", router->nickname);
+//  log_fn(LOG_INFO,"Picked %s.", router->nickname);
   return router;
 }
 
@@ -304,11 +307,11 @@
   routerinfo_t *choice;
 
   excludednodes = smartlist_create();
-  add_nickname_list_to_smartlist(excludednodes,excluded);
+  add_nickname_list_to_smartlist(excludednodes,excluded,0);
 
   /* try the preferred nodes first */
   sl = smartlist_create();
-  add_nickname_list_to_smartlist(sl,preferred);
+  add_nickname_list_to_smartlist(sl,preferred,1);
   smartlist_subtract(sl,excludednodes);
   if(excludedsmartlist)
     smartlist_subtract(sl,excludedsmartlist);



More information about the tor-commits mailing list