[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] make hidden services more likely to work from the server-side



Update of /home2/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv18707

Modified Files:
	circuituse.c or.h rendservice.c 
Log Message:
make hidden services more likely to work from the server-side


Index: circuituse.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/circuituse.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- circuituse.c	17 Mar 2005 12:38:35 -0000	1.55
+++ circuituse.c	19 Mar 2005 04:38:58 -0000	1.56
@@ -656,13 +656,10 @@
       /* at Bob, connecting to rend point */
       /* Don't increment failure count, since Alice may have picked
        * the rendezvous point maliciously */
-      if (failed_at_last_hop) {
-        log_fn(LOG_INFO,"Couldn't connect to Alice's chosen rend point %s. Sucks to be Alice.", circ->build_state->chosen_exit_name);
-      } else {
-        log_fn(LOG_INFO,"Couldn't connect to Alice's chosen rend point %s, because an earlier node failed.",
-               circ->build_state->chosen_exit_name);
-        rend_service_relaunch_rendezvous(circ);
-      }
+      log_fn(LOG_INFO,"Couldn't connect to Alice's chosen rend point %s (%s hop failed).",
+             failed_at_last_hop?"last":"non-last",
+             circ->build_state->chosen_exit_name);
+      rend_service_relaunch_rendezvous(circ);
       break;
     default:
       /* Other cases are impossible, since this function is only called with

Index: or.h
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.558
retrieving revision 1.559
diff -u -d -r1.558 -r1.559
--- or.h	17 Mar 2005 12:38:36 -0000	1.558
+++ or.h	19 Mar 2005 04:38:59 -0000	1.559
@@ -786,6 +786,8 @@
   struct crypt_path_t *pending_final_cpath;
   /** How many times has building a circuit for this task failed? */
   int failure_count;
+  /** At what time should we give up on this task? */
+  time_t expiry_time;
 } cpath_build_state_t;
 
 #define CIRCUIT_MAGIC 0x35315243u

Index: rendservice.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/rendservice.c,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -d -r1.118 -r1.119
--- rendservice.c	27 Feb 2005 22:08:01 -0000	1.118
+++ rendservice.c	19 Mar 2005 04:38:59 -0000	1.119
@@ -31,7 +31,10 @@
 #define MAX_INTRO_CIRCS_PER_PERIOD 10
 /** How many times will a hidden service operator attempt to connect to
  * a requested rendezvous point before giving up? */
-#define MAX_REND_FAILURES 3
+#define MAX_REND_FAILURES 30
+/** How many seconds should we spend trying to connect to a requested
+ * rendezvous point before giving up? */
+#define MAX_REND_TIMEOUT 30
 
 /** Represents a single hidden service running at this OP. */
 typedef struct rend_service_t {
@@ -505,6 +508,7 @@
           sizeof(launched->rend_query));
   launched->build_state->pending_final_cpath = cpath =
     tor_malloc_zero(sizeof(crypt_path_t));
+  launched->build_state->expiry_time = time(NULL) + MAX_REND_TIMEOUT;
 
   cpath->handshake_state = dh;
   dh = NULL;
@@ -531,8 +535,9 @@
   tor_assert(oldcirc->purpose == CIRCUIT_PURPOSE_S_CONNECT_REND);
 
   if (!oldcirc->build_state ||
-      oldcirc->build_state->failure_count > MAX_REND_FAILURES) {
-    log_fn(LOG_INFO,"Attempt to build circuit to %s for rendezvous has failed too many times; giving up.",
+      oldcirc->build_state->failure_count > MAX_REND_FAILURES ||
+      oldcirc->build_state->expiry_time < time(NULL)) {
+    log_fn(LOG_INFO,"Attempt to build circuit to %s for rendezvous has failed too many times or expired; giving up.",
            oldcirc->build_state->chosen_exit_name);
     return;
   }
@@ -558,6 +563,7 @@
   newstate = newcirc->build_state;
   tor_assert(newstate);
   newstate->failure_count = oldstate->failure_count+1;
+  newstate->expiry_time = oldstate->expiry_time;
   newstate->pending_final_cpath = oldstate->pending_final_cpath;
   oldstate->pending_final_cpath = NULL;