]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
tolerate old 0.0.7 clients that demand a certain ip:port for a router
authorRoger Dingledine <arma@torproject.org>
Wed, 18 Aug 2004 11:20:15 +0000 (11:20 +0000)
committerRoger Dingledine <arma@torproject.org>
Wed, 18 Aug 2004 11:20:15 +0000 (11:20 +0000)
even though it's moved on to another one.

also reduce some log verbosity.

svn:r2288

src/or/circuitbuild.c
src/or/command.c
src/or/or.h
src/or/routerlist.c

index 9a4549258919bd3c7cdc0f66359fd4c0305b65ec..e64d4a934349d1c4361fdc674da75b4e111df7ca 100644 (file)
@@ -435,6 +435,7 @@ int circuit_extend(cell_t *cell, circuit_t *circ) {
   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 @@ int circuit_extend(cell_t *cell, circuit_t *circ) {
   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 @@ int circuit_extend(cell_t *cell, circuit_t *circ) {
      /* 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 @@ static routerinfo_t *choose_good_exit_server_general(routerlist_t *dir)
   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 @@ static routerinfo_t *choose_good_exit_server_general(routerlist_t *dir)
          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 @@ onion_extend_cpath(crypt_path_t **head_ptr, cpath_build_state_t
          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 284c4c6a9c01bc632702665ea176e7a2383e542b..f80dd6fcea2d88f126a7c508bbd737fd30ee3f15 100644 (file)
@@ -48,7 +48,7 @@ static void command_time_process_cell(cell_t *cell, connection_t *conn, int *tim
   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 36fd64fbe0026b8bccd66adb6935b9f3c274c598..8d52eb8a28d50607f9ba42a2624f2c872750d0a3 100644 (file)
@@ -1394,7 +1394,7 @@ int is_legal_nickname_or_hexdigest(const char *s);
 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 d24286a0b0026ed5061c32f4c5e571a5f8808026..cda2ef5fda62d6fb36b11c1137cc1f42d751ab54 100644 (file)
@@ -152,7 +152,9 @@ int all_directory_servers_down(void) {
  * 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 @@ void add_nickname_list_to_smartlist(smartlist_t *sl, const char *list) {
       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 @@ routerlist_sl_choose_by_bandwidth(smartlist_t *sl)
   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 *router_choose_random_node(char *preferred, char *excluded,
   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);