[or-cvs] r13583: If we only ever used Tor for hidden service lookups or posts (in tor/trunk: . src/or)

arma at seul.org arma at seul.org
Tue Feb 19 21:30:25 UTC 2008


Author: arma
Date: 2008-02-19 16:30:24 -0500 (Tue, 19 Feb 2008)
New Revision: 13583

Modified:
   tor/trunk/ChangeLog
   tor/trunk/src/or/connection_edge.c
   tor/trunk/src/or/directory.c
   tor/trunk/src/or/rephist.c
Log:
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.


Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2008-02-19 21:08:27 UTC (rev 13582)
+++ tor/trunk/ChangeLog	2008-02-19 21:30:24 UTC (rev 13583)
@@ -8,6 +8,10 @@
     - 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 @@
       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:

Modified: tor/trunk/src/or/connection_edge.c
===================================================================
--- tor/trunk/src/or/connection_edge.c	2008-02-19 21:08:27 UTC (rev 13582)
+++ tor/trunk/src/or/connection_edge.c	2008-02-19 21:30:24 UTC (rev 13583)
@@ -1244,6 +1244,7 @@
   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 @@
         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 @@
 
       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_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 @@
 /** 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) {

Modified: tor/trunk/src/or/directory.c
===================================================================
--- tor/trunk/src/or/directory.c	2008-02-19 21:08:27 UTC (rev 13582)
+++ tor/trunk/src/or/directory.c	2008-02-19 21:30:24 UTC (rev 13583)
@@ -688,6 +688,14 @@
     }
   } 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

Modified: tor/trunk/src/or/rephist.c
===================================================================
--- tor/trunk/src/or/rephist.c	2008-02-19 21:08:27 UTC (rev 13582)
+++ tor/trunk/src/or/rephist.c	2008-02-19 21:30:24 UTC (rev 13583)
@@ -1546,6 +1546,7 @@
     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())



More information about the tor-commits mailing list