aboutsummaryrefslogtreecommitdiff
path: root/src/or/onion.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-04-12 18:40:14 +0000
committerRoger Dingledine <arma@torproject.org>2004-04-12 18:40:14 +0000
commitc5052bec9543e0fea56856020566130a03a7c831 (patch)
treea4a0800f86c63db2adc33ae42885c5b51ac9a4a8 /src/or/onion.c
parentfc5a7662983e1711b91a486093e1f0ad220d7fcc (diff)
downloadtor-c5052bec9543e0fea56856020566130a03a7c831.tar.gz
tor-c5052bec9543e0fea56856020566130a03a7c831.zip
normal circs are 3 hops, but rend/intro circs are 4, because
the initiator doesn't get to choose the last hop svn:r1595
Diffstat (limited to 'src/or/onion.c')
-rw-r--r--src/or/onion.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/or/onion.c b/src/or/onion.c
index c8b0f5c6c3..c827d0e346 100644
--- a/src/or/onion.c
+++ b/src/or/onion.c
@@ -160,7 +160,7 @@ int onionskin_answer(circuit_t *circ, unsigned char *payload, unsigned char *key
extern int has_fetched_directory;
-static int new_route_len(double cw, smartlist_t *routers) {
+static int new_route_len(double cw, uint8_t purpose, smartlist_t *routers) {
int num_acceptable_routers;
int routelen;
@@ -169,7 +169,16 @@ static int new_route_len(double cw, smartlist_t *routers) {
#ifdef TOR_PERF
routelen = 2;
#else
- routelen = 3;
+ if(purpose == CIRCUIT_PURPOSE_C_GENERAL)
+ routelen = 3;
+ else if(purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND)
+ routelen = 4;
+ else if(purpose == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO)
+ routelen = 4;
+ else {
+ log_fn(LOG_WARN,"Unhandled purpose %d", purpose);
+ return -1;
+ }
#endif
#if 0
for(routelen = 3; ; routelen++) { /* 3, increment until coinflip says we're done */
@@ -360,7 +369,7 @@ cpath_build_state_t *onion_new_cpath_build_state(uint8_t purpose,
routerinfo_t *exit;
router_get_routerlist(&rl);
- r = new_route_len(options.PathlenCoinWeight, rl->routers);
+ r = new_route_len(options.PathlenCoinWeight, purpose, rl->routers);
if (r < 0)
return NULL;
info = tor_malloc_zero(sizeof(cpath_build_state_t));