diff options
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/connection_edge.c | 14 | ||||
-rw-r--r-- | src/or/directory.c | 8 | ||||
-rw-r--r-- | src/or/rephist.c | 1 |
3 files changed, 19 insertions, 4 deletions
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index 15bea7f632..6c6850d04d 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -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) { diff --git a/src/or/directory.c b/src/or/directory.c index 7a5990105e..f1c0e02ec2 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -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 diff --git a/src/or/rephist.c b/src/or/rephist.c index 5153d719f7..429cd0e68e 100644 --- a/src/or/rephist.c +++ b/src/or/rephist.c @@ -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()) |