aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-08-17 07:09:02 +0000
committerRoger Dingledine <arma@torproject.org>2004-08-17 07:09:02 +0000
commit2d8a1f208a0c1ad78a376b229df6efdf980186b1 (patch)
treedffded20a050d33b82a0e33a992a5942bc272b84
parent9e5fc55564fdd13454690998ad2d8cb858c7f7fe (diff)
downloadtor-2d8a1f208a0c1ad78a376b229df6efdf980186b1.tar
tor-2d8a1f208a0c1ad78a376b229df6efdf980186b1.tar.gz
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 svn:r2252
-rw-r--r--src/or/circuitbuild.c15
-rw-r--r--src/or/connection.c2
2 files changed, 13 insertions, 4 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 81b88e5bb..51ee835e4 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -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);
diff --git a/src/or/connection.c b/src/or/connection.c
index 74da0d6d0..8866ddbb4 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -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;