If we only ever used Tor for hidden service lookups or posts, we

would stop building circuits and start refusing connections after
24 hours, since we false believed that Tor was dormant. Reported
by nwf; bugfix on 0.1.2.x.


svn:r13583
This commit is contained in:
Roger Dingledine 2008-02-19 21:30:24 +00:00
parent 33c754315b
commit d964beac16
4 changed files with 24 additions and 5 deletions

View File

@ -8,6 +8,10 @@ Changes in version 0.2.0.20-?? - 2008-02-??
- Resolved problems with (re-)fetching hidden service descriptors.
Patch from Karsten Loesing; fixes problems with 0.2.0.18-alpha
and 0.2.0.19-alpha.
- If we only ever used Tor for hidden service lookups or posts, we
would stop building circuits and start refusing connections after
24 hours, since we false believed that Tor was dormant. Reported
by nwf; bugfix on 0.1.2.x.
o Minor features (performance):
- Tune parameters for cell pool allocation to minimize amount of
@ -32,7 +36,7 @@ Changes in version 0.2.0.20-?? - 2008-02-??
network; it was producing too many wrong guesses.
- We were leaking a file descriptor if Tor started with a zero-length
cached-descriptors file. Patch by freddy77; bugfix on 0.1.2.
- Have the new hidden service code respect the SafeLogging setting.
- Make the new hidden service code respect the SafeLogging setting.
Bugfix on 0.2.0.x. Patch from Karsten.
o Code simplifications and refactoring:

View File

@ -1244,6 +1244,7 @@ connection_ap_handshake_rewrite_and_attach(edge_connection_t *conn,
int automap = 0;
char orig_address[MAX_SOCKS_ADDR_LEN];
time_t map_expires = TIME_MAX;
time_t now = time(NULL);
tor_strlower(socks->address); /* normalize it */
strlcpy(orig_address, socks->address, sizeof(orig_address));
@ -1406,7 +1407,7 @@ connection_ap_handshake_rewrite_and_attach(edge_connection_t *conn,
return 0;
}
tor_assert(!automap);
rep_hist_note_used_resolve(time(NULL)); /* help predict this next time */
rep_hist_note_used_resolve(now); /* help predict this next time */
} else if (socks->command == SOCKS_COMMAND_CONNECT) {
tor_assert(!automap);
if (socks->port == 0) {
@ -1438,10 +1439,10 @@ connection_ap_handshake_rewrite_and_attach(edge_connection_t *conn,
if (!conn->use_begindir) {
/* help predict this next time */
rep_hist_note_used_port(socks->port, time(NULL));
rep_hist_note_used_port(socks->port, now);
}
} else if (socks->command == SOCKS_COMMAND_RESOLVE_PTR) {
rep_hist_note_used_resolve(time(NULL)); /* help predict this next time */
rep_hist_note_used_resolve(now); /* help predict this next time */
/* no extra processing needed */
} else {
tor_fragile_assert();
@ -1491,6 +1492,11 @@ connection_ap_handshake_rewrite_and_attach(edge_connection_t *conn,
connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);
return -1;
}
/* Help predict this next time. We're not sure if it will need
* a stable circuit yet, but we know we'll need *something*. */
rep_hist_note_used_internal(now, 0, 1);
if (r==0) {
conn->_base.state = AP_CONN_STATE_RENDDESC_WAIT;
log_info(LD_REND, "Unknown descriptor %s. Fetching.",
@ -1503,7 +1509,7 @@ connection_ap_handshake_rewrite_and_attach(edge_connection_t *conn,
/** How long after we receive a hidden service descriptor do we consider
* it valid? */
#define NUM_SECONDS_BEFORE_HS_REFETCH (60*15)
if (time(NULL) - entry->received < NUM_SECONDS_BEFORE_HS_REFETCH) {
if (now - entry->received < NUM_SECONDS_BEFORE_HS_REFETCH) {
conn->_base.state = AP_CONN_STATE_CIRCUIT_WAIT;
log_info(LD_REND, "Descriptor is here and fresh enough. Great.");
if (connection_ap_handshake_attach_circuit(conn) < 0) {

View File

@ -688,6 +688,14 @@ directory_initiate_command(const char *address, uint32_t addr,
}
} else { /* we want to connect via a tor connection */
edge_connection_t *linked_conn;
/* If it's an anonymized connection, remember the fact that we
* wanted it for later: maybe we'll want it again soon. */
if (anonymized_connection && use_begindir)
rep_hist_note_used_internal(now, 0, 1);
else if (anonymized_connection && !use_begindir)
rep_hist_note_used_port(time(NULL), conn->_base.port);
/* make an AP connection
* populate it and add it at the right state
* hook up both sides

View File

@ -1546,6 +1546,7 @@ rep_hist_circbuilding_dormant(time_t now)
return 0;
/* see if we'll still need to build testing circuits */
//XXX020 actually, is it orport_reachable or still-doing-bandwidth-tests?
if (server_mode(get_options()) && !check_whether_orport_reachable())
return 0;
if (!check_whether_dirport_reachable())