aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2005-09-10 01:01:40 +0000
committerRoger Dingledine <arma@torproject.org>2005-09-10 01:01:40 +0000
commit1d9786a3927fa4342e0396a02a962fcaea017708 (patch)
tree6e15a36a0a3c05bb8e8f13519d43c06f902348b7
parent035b1953eba11febfd975727b7101f7bd423c3fc (diff)
downloadtor-1d9786a3927fa4342e0396a02a962fcaea017708.tar.gz
tor-1d9786a3927fa4342e0396a02a962fcaea017708.zip
generalize route length to three plus one if the exit node is risky.
svn:r4978
-rw-r--r--src/or/circuitbuild.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 29193f9955..12e34f8ee2 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -894,7 +894,8 @@ onionskin_answer(circuit_t *circ, uint8_t cell_type, char *payload, char *keys)
* is feasible, except if it's less than 2, in which case return -1.
*/
static int
-new_route_len(double cw, uint8_t purpose, smartlist_t *routers)
+new_route_len(double cw, uint8_t purpose, extend_info_t *exit,
+ smartlist_t *routers)
{
int num_acceptable_routers;
int routelen;
@@ -906,23 +907,11 @@ new_route_len(double cw, uint8_t purpose, smartlist_t *routers)
#ifdef TOR_PERF
routelen = 2;
#else
- if (purpose == CIRCUIT_PURPOSE_C_GENERAL)
- routelen = 3;
- else if (purpose == CIRCUIT_PURPOSE_TESTING)
- routelen = 3;
- else if (purpose == CIRCUIT_PURPOSE_C_INTRODUCING)
- routelen = 4;
- else if (purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND)
- routelen = 3;
- else if (purpose == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO)
- routelen = 3;
- else if (purpose == CIRCUIT_PURPOSE_S_CONNECT_REND)
- routelen = 4;
- else {
- log_fn(LOG_WARN,"Bug: unhandled purpose %d", purpose);
- tor_fragile_assert();
- return -1;
- }
+ routelen = 3;
+ if (exit &&
+ purpose != CIRCUIT_PURPOSE_TESTING &&
+ purpose != CIRCUIT_PURPOSE_S_ESTABLISH_INTRO)
+ routelen++;
#endif
log_fn(LOG_DEBUG,"Chosen route length %d (%d routers available).",routelen,
smartlist_len(routers));
@@ -1259,7 +1248,8 @@ onion_pick_cpath_exit(circuit_t *circ, extend_info_t *exit)
log_fn(LOG_WARN,"router_get_routerlist returned empty list; closing circ.");
return -1;
}
- r = new_route_len(get_options()->PathlenCoinWeight, circ->purpose, rl->routers);
+ r = new_route_len(get_options()->PathlenCoinWeight, circ->purpose,
+ exit, rl->routers);
if (r < 1) /* must be at least 1 */
return -1;
state->desired_path_len = r;