diff options
author | Roger Dingledine <arma@torproject.org> | 2005-01-17 18:13:09 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2005-01-17 18:13:09 +0000 |
commit | d2400a5afd70b009b632b307205273fc25c8cd92 (patch) | |
tree | 5a25d9d3a30fb61f43c53387397e8529544775c2 /src/or/rephist.c | |
parent | 9c8c90ec2f2ae0d83effbaa3a13077dfc9dd975c (diff) | |
download | tor-d2400a5afd70b009b632b307205273fc25c8cd92.tar.gz tor-d2400a5afd70b009b632b307205273fc25c8cd92.zip |
Introduce a notion of 'internal' circs, which are chosen without regard
to the exit policy of the last hop. Intro and rendezvous circs must
be internal circs, to avoid leaking information. Resolve and connect
streams can use internal circs if they want.
New circuit pooling algorithm: make sure to have enough circs around
to satisfy any predicted ports, and also make sure to have 2 internal
circs around if we've required internal circs lately (with high uptime
if we've seen that lately).
Split NewCircuitPeriod config option into NewCircuitPeriod (30 secs),
which describes how often we retry making new circuits if current ones
are dirty, and MaxCircuitDirtiness (10 mins), which describes how long
we're willing to make use of an already-dirty circuit.
Once rendezvous circuits are established, keep using the same circuit as
long as you attach a new stream to it at least every 10 minutes. (So web
browsing doesn't require you to build new rend circs every 30 seconds.)
Cannibalize GENERAL circs to be C_REND, C_INTRO, S_INTRO, and S_REND
circ as necessary, if there are any completed ones lying around when
we try to launch one.
Re-instate the ifdef's to use version-0 style introduce cells, since
there was yet another bug in handling version-1 style. We'll try switching
over again after 0.0.9 is obsolete.
Bugfix: when choosing an exit node for a new non-internal circ, don't take
into account whether it'll be useful for any pending x.onion addresses --
it won't.
Bugfix: we weren't actually publishing the hidden service descriptor when
it became dirty. So we only published it every 20 minutes or so, which
means when you first start your Tor, the hidden service will seem broken.
svn:r3360
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r-- | src/or/rephist.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c index 568988f269..4537032803 100644 --- a/src/or/rephist.c +++ b/src/or/rephist.c @@ -666,7 +666,7 @@ void rep_hist_note_used_port(uint16_t port, time_t now) { add_predicted_port(port, now); } -#define PREDICTED_PORTS_RELEVANCE_TIME (6*3600) /* 6 hours */ +#define PREDICTED_CIRCS_RELEVANCE_TIME (3600) /* 1 hour */ /** Return a pointer to the list of port numbers that * are likely to be asked for in the near future. @@ -684,7 +684,7 @@ smartlist_t *rep_hist_get_predicted_ports(time_t now) { /* clean out obsolete entries */ for (i = 0; i < smartlist_len(predicted_ports_list); ++i) { tmp_time = smartlist_get(predicted_ports_times, i); - if (*tmp_time + PREDICTED_PORTS_RELEVANCE_TIME < now) { + if (*tmp_time + PREDICTED_CIRCS_RELEVANCE_TIME < now) { tmp_port = smartlist_get(predicted_ports_list, i); log_fn(LOG_DEBUG, "Expiring predicted port %d", *tmp_port); smartlist_del(predicted_ports_list, i); @@ -697,3 +697,36 @@ smartlist_t *rep_hist_get_predicted_ports(time_t now) { return predicted_ports_list; } +/** The last time at which we needed an internal circ. */ +static time_t predicted_hidserv_time = 0; +/** The last time we needed an internal circ with good uptime. */ +static time_t predicted_hidserv_uptime_time = 0; +/** The last time we needed an internal circ with good capacity. */ +static time_t predicted_hidserv_capacity_time = 0; + +/** Remember that we used an internal circ at time <b>now</b>. */ +void rep_hist_note_used_hidserv(time_t now, int need_uptime, int need_capacity) { + predicted_hidserv_time = now; + if (need_uptime) + predicted_hidserv_uptime_time = now; + if (need_capacity) + predicted_hidserv_capacity_time = now; +} + +/** Return 1 if we've used an internal circ recently; else return 0. */ +int rep_hist_get_predicted_hidserv(time_t now, int *need_uptime, int *need_capacity) { + if (!predicted_hidserv_time) /* initialize it */ + predicted_hidserv_time = now; + if (predicted_hidserv_time + PREDICTED_CIRCS_RELEVANCE_TIME < now) + return 0; /* too long ago */ + if (predicted_hidserv_uptime_time + PREDICTED_CIRCS_RELEVANCE_TIME < now) + *need_uptime = 1; + if (predicted_hidserv_capacity_time + PREDICTED_CIRCS_RELEVANCE_TIME < now) + *need_capacity = 1; + return 1; +} + +/* not used yet */ +void rep_hist_note_used_resolve(time_t now) { } +int rep_hist_get_predicted_resolve(time_t now) { return 0; } + |