[or-cvs] when only one router is labelled as a guard, and we"ve
arma at seul.org
arma at seul.org
Fri Jun 9 09:02:34 UTC 2006
Update of /home2/or/cvsroot/tor/src/or
In directory moria:/home/arma/work/onion/cvs/tor/src/or
Modified Files:
circuitbuild.c
Log Message:
when only one router is labelled as a guard, and we've
already picked him, we would cycle endlessly picking him
again, being unhappy about it, and so forth.
now we specifically exclude guards when picking a new guard.
Index: circuitbuild.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/circuitbuild.c,v
retrieving revision 1.240
retrieving revision 1.241
diff -u -p -d -r1.240 -r1.241
--- circuitbuild.c 7 Jun 2006 07:11:42 -0000 1.240
+++ circuitbuild.c 9 Jun 2006 09:02:32 -0000 1.241
@@ -716,9 +716,6 @@ circuit_extend(cell_t *cell, circuit_t *
if (!n_conn || n_conn->state != OR_CONN_STATE_OPEN ||
(n_conn->is_obsolete &&
router_digest_version_as_new_as(id_digest,"0.1.1.9-alpha-cvs"))) {
- /* Note that this will close circuits that have the same
- * router twice in a row in the path. I think that's ok.
- */
struct in_addr in;
char tmpbuf[INET_NTOA_BUF_LEN];
in.s_addr = htonl(circ->n_addr);
@@ -1552,6 +1549,14 @@ choose_good_entry_server(uint8_t purpose
smartlist_add(excluded, r);
}
}
+ /* and exclude current entry guards, if applicable */
+ if (options->UseEntryGuards && entry_guards) {
+ SMARTLIST_FOREACH(entry_guards, entry_guard_t *, entry,
+ {
+ if ((r = router_get_by_digest(entry->identity)))
+ smartlist_add(excluded, r);
+ });
+ }
// XXX we should exclude busy exit nodes here, too,
// but only if there are enough other nodes available.
choice = router_choose_random_node(
@@ -1799,7 +1804,7 @@ log_entry_guards(int severity)
#define NUM_ENTRY_PICK_TRIES 100
-/** Add a new (preferably stable and fast) entry to our
+/** Add a new (preferably stable and fast) router to our
* entry_guards list. Return a pointer to the router if we succeed,
* or NULL if we can't find any more suitable entries.
*
@@ -1811,33 +1816,20 @@ add_an_entry_guard(routerinfo_t *chosen)
{
routerinfo_t *router;
entry_guard_t *entry;
- int tries_left = NUM_ENTRY_PICK_TRIES;
-again:
- if (--tries_left <= 0) {
- log_warn(LD_CIRC, "Tried finding a new entry guard, but failed. "
- "Can you reach the Tor network?");
- return NULL;
- }
if (chosen)
router = chosen;
else
router = choose_good_entry_server(CIRCUIT_PURPOSE_C_GENERAL, NULL);
if (!router)
return NULL;
- /* make sure it's not already an entry */
- if (is_an_entry_guard(router->cache_info.identity_digest)) {
- if (chosen)
- return NULL;
- goto again;
- }
entry = tor_malloc_zero(sizeof(entry_guard_t));
log_info(LD_CIRC, "Chose '%s' as new entry guard.", router->nickname);
strlcpy(entry->nickname, router->nickname, sizeof(entry->nickname));
memcpy(entry->identity, router->cache_info.identity_digest, DIGEST_LEN);
- if (chosen)
+ if (chosen) /* prepend */
smartlist_insert(entry_guards, 0, entry);
- else
+ else /* append */
smartlist_add(entry_guards, entry);
log_entry_guards(LOG_INFO);
return router;
More information about the tor-commits
mailing list