[or-cvs] if they ask for exactly one entrynode, don"t pick it as an ...
Roger Dingledine
arma at seul.org
Tue Aug 17 07:09:04 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 connection.c
Log Message:
if they ask for exactly one entrynode, don't pick it as an exitnode.
also, fix part of the zero-identity-router-in-stats bug
Index: circuitbuild.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuitbuild.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- circuitbuild.c 17 Aug 2004 06:27:32 -0000 1.24
+++ circuitbuild.c 17 Aug 2004 07:09:02 -0000 1.25
@@ -798,9 +798,12 @@
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 @@
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 @@
}
smartlist_free(preferredexits);
+ smartlist_free(preferredentries);
smartlist_free(excludedexits);
smartlist_free(sl);
tor_free(n_supported);
@@ -926,7 +936,7 @@
}
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(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: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.249
retrieving revision 1.250
diff -u -d -r1.249 -r1.250
--- connection.c 16 Aug 2004 11:43:18 -0000 1.249
+++ connection.c 17 Aug 2004 07:09:02 -0000 1.250
@@ -199,7 +199,7 @@
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;
More information about the tor-commits
mailing list