]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
if they ask for exactly one entrynode, don't pick it as an exitnode.
authorRoger Dingledine <arma@torproject.org>
Tue, 17 Aug 2004 07:09:02 +0000 (07:09 +0000)
committerRoger Dingledine <arma@torproject.org>
Tue, 17 Aug 2004 07:09:02 +0000 (07:09 +0000)
also, fix part of the zero-identity-router-in-stats bug

svn:r2252

src/or/circuitbuild.c
src/or/connection.c

index 81b88e5bbcf9e85a68968e0ff8857bd4dfe2b330..51ee835e49df29b864e3f1b3aedc20356a185cfc 100644 (file)
@@ -798,9 +798,12 @@ static routerinfo_t *choose_good_exit_server_general(routerlist_t *dir)
   int n_connections;
   int best_support = -1;
   int n_best_support=0;
-  smartlist_t *sl, *preferredexits, *excludedexits;
+  smartlist_t *sl, *preferredexits, *preferredentries, *excludedexits;
   routerinfo_t *router;
 
+  preferredentries = smartlist_create();
+  add_nickname_list_to_smartlist(preferredentries,options.EntryNodes);
+
   get_connection_array(&carray, &n_connections);
 
   /* Count how many connections are waiting for a circuit to be built.
@@ -850,6 +853,12 @@ static routerinfo_t *choose_good_exit_server_general(routerlist_t *dir)
              router->nickname, i);
       continue; /* skip routers that reject all */
     }
+    if(smartlist_len(preferredentries)==1 &&
+       router == (routerinfo_t*)smartlist_get(preferredentries, 0)) {
+      n_supported[i] = -1;
+      log_fn(LOG_DEBUG,"Skipping node %s (index %d) -- it's our only preferred entry node.", router->nickname, i);
+      continue;
+    }
     n_supported[i] = 0;
     for (j = 0; j < n_connections; ++j) { /* iterate over connections */
       if (carray[j]->type != CONN_TYPE_AP ||
@@ -917,6 +926,7 @@ static routerinfo_t *choose_good_exit_server_general(routerlist_t *dir)
   }
 
   smartlist_free(preferredexits);
+  smartlist_free(preferredentries);
   smartlist_free(excludedexits);
   smartlist_free(sl);
   tor_free(n_supported);
@@ -926,7 +936,7 @@ static routerinfo_t *choose_good_exit_server_general(routerlist_t *dir)
   }
   if (options.StrictExitNodes)
     log_fn(LOG_WARN, "No exit routers seem to be running; can't choose an exit.");
-  
+
   return NULL;
 }
 
@@ -943,7 +953,6 @@ static routerinfo_t *choose_good_exit_server_general(routerlist_t *dir)
 static routerinfo_t *choose_good_exit_server(uint8_t purpose, routerlist_t *dir)
 {
   routerinfo_t *r;
-  /* XXX one day, consider picking chosen_exit knowing what's in EntryNodes */
   switch(purpose) {
     case CIRCUIT_PURPOSE_C_GENERAL:
       return choose_good_exit_server_general(dir);
index 74da0d6d07a9781b99e0cc6c6769d86f4860acc1..8866ddbb48a7f00a9db569b5cb1ddbc40a7f485b 100644 (file)
@@ -199,7 +199,7 @@ void connection_about_to_close_connection(connection_t *conn)
           rep_hist_note_connect_failed(conn->identity_digest, time(NULL));
       } else if (0) { // XXX reason == CLOSE_REASON_UNUSED_OR_CONN) {
         rep_hist_note_disconnect(conn->identity_digest, time(NULL));
-      } else {
+      } else if(conn->identity_digest) {
         rep_hist_note_connection_died(conn->identity_digest, time(NULL));
       }
       break;