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

[or-cvs] let the circuit-launcher choose the exit node (if he wants)



Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	circuit.c connection_edge.c main.c onion.c or.h rendservice.c 
Log Message:
let the circuit-launcher choose the exit node (if he wants)


Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.164
retrieving revision 1.165
diff -u -d -r1.164 -r1.165
--- circuit.c	1 Apr 2004 03:23:27 -0000	1.164
+++ circuit.c	1 Apr 2004 03:44:49 -0000	1.165
@@ -15,7 +15,7 @@
 
 static void circuit_is_ready(circuit_t *circ);
 static void circuit_failed(circuit_t *circ);
-static circuit_t *circuit_establish_circuit(uint8_t purpose);
+static circuit_t *circuit_establish_circuit(uint8_t purpose, const char *exit_nickname);
 
 unsigned long stats_n_relay_cells_relayed = 0;
 unsigned long stats_n_relay_cells_delivered = 0;
@@ -1052,7 +1052,7 @@
 static int n_circuit_failures = 0;
 
 /* Launch a new circuit and return a pointer to it. Return NULL if you failed. */
-circuit_t *circuit_launch_new(uint8_t purpose) {
+circuit_t *circuit_launch_new(uint8_t purpose, const char *exit_nickname) {
 
   if(!(options.SocksPort||options.RunTesting)) /* no need for circuits. */
     return NULL;
@@ -1063,7 +1063,7 @@
   }
 
   /* try a circ. if it fails, circuit_mark_for_close will increment n_circuit_failures */
-  return circuit_establish_circuit(purpose);
+  return circuit_establish_circuit(purpose, exit_nickname);
 }
 
 void circuit_increment_failure_count(void) {
@@ -1075,14 +1075,15 @@
   n_circuit_failures = 0;
 }
 
-static circuit_t *circuit_establish_circuit(uint8_t purpose) {
+static circuit_t *circuit_establish_circuit(uint8_t purpose,
+                                            const char *exit_nickname) {
   routerinfo_t *firsthop;
   connection_t *n_conn;
   circuit_t *circ;
 
   circ = circuit_new(0, NULL); /* sets circ->p_circ_id and circ->p_conn */
   circ->state = CIRCUIT_STATE_OR_WAIT;
-  circ->build_state = onion_new_cpath_build_state();
+  circ->build_state = onion_new_cpath_build_state(exit_nickname);
   circ->purpose = purpose;
 
   if (! circ->build_state) {

Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -d -r1.123 -r1.124
--- connection_edge.c	1 Apr 2004 02:41:41 -0000	1.123
+++ connection_edge.c	1 Apr 2004 03:44:49 -0000	1.124
@@ -758,7 +758,7 @@
     case 0: /* no useful circuits available */
       if(!circuit_get_newest(conn, 0, must_be_clean)) {
         /* is one already on the way? */
-        circuit_launch_new(CIRCUIT_PURPOSE_C_GENERAL);
+        circuit_launch_new(CIRCUIT_PURPOSE_C_GENERAL, NULL);
       }
       return 0;
     default: /* case 1, it succeeded, great */

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.219
retrieving revision 1.220
diff -u -d -r1.219 -r1.220
--- main.c	1 Apr 2004 03:23:28 -0000	1.219
+++ main.c	1 Apr 2004 03:44:49 -0000	1.220
@@ -391,11 +391,12 @@
       circuit_reset_failure_count();
       if(circ && circ->timestamp_dirty) {
         log_fn(LOG_INFO,"Youngest circuit dirty; launching replacement.");
-        circuit_launch_new(CIRCUIT_PURPOSE_C_GENERAL); /* make a new circuit */
+        /* make a new circuit */
+        circuit_launch_new(CIRCUIT_PURPOSE_C_GENERAL, NULL);
       } else if (options.RunTesting && circ &&
                  circ->timestamp_created + TESTING_CIRCUIT_INTERVAL < now) {
         log_fn(LOG_INFO,"Creating a new testing circuit.");
-        circuit_launch_new(CIRCUIT_PURPOSE_C_GENERAL);
+        circuit_launch_new(CIRCUIT_PURPOSE_C_GENERAL, NULL);
       }
       time_to_new_circuit = now + options.NewCircuitPeriod;
     }
@@ -404,7 +405,7 @@
       /* if there's no open circ, and less than 3 are on the way,
        * go ahead and try another.
        */
-      circuit_launch_new(CIRCUIT_PURPOSE_C_GENERAL);
+      circuit_launch_new(CIRCUIT_PURPOSE_C_GENERAL, NULL);
     }
   }
 

Index: onion.c
===================================================================
RCS file: /home/or/cvsroot/src/or/onion.c,v
retrieving revision 1.134
retrieving revision 1.135
diff -u -d -r1.134 -r1.135
--- onion.c	30 Mar 2004 22:59:00 -0000	1.134
+++ onion.c	1 Apr 2004 03:44:49 -0000	1.135
@@ -347,7 +347,7 @@
   return NULL;
 }
 
-cpath_build_state_t *onion_new_cpath_build_state(void) {
+cpath_build_state_t *onion_new_cpath_build_state(const char *exit_nickname) {
   routerlist_t *rl;
   int r;
   cpath_build_state_t *info;
@@ -357,12 +357,19 @@
   r = new_route_len(options.PathlenCoinWeight, rl->routers, rl->n_routers);
   if (r < 0)
     return NULL;
-  exit = choose_good_exit_server(rl);
-  if(!exit)
-    return NULL;
   info = tor_malloc(sizeof(cpath_build_state_t));
   info->desired_path_len = r;
-  info->chosen_exit = tor_strdup(exit->nickname);
+  if(exit_nickname) { /* the circuit-builder pre-requested one */
+    log_fn(LOG_INFO,"Using requested exit node '%s'", exit_nickname);
+    info->chosen_exit = tor_strdup(exit_nickname);
+  } else { /* we have to decide one */
+    exit = choose_good_exit_server(rl);
+    if(!exit) {
+      tor_free(info);
+      return NULL;
+    }
+    info->chosen_exit = tor_strdup(exit->nickname);
+  }
   return info;
 }
 

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.273
retrieving revision 1.274
diff -u -d -r1.273 -r1.274
--- or.h	1 Apr 2004 03:23:28 -0000	1.273
+++ or.h	1 Apr 2004 03:44:49 -0000	1.274
@@ -689,7 +689,7 @@
 void circuit_dump_by_conn(connection_t *conn, int severity);
 
 void circuit_expire_unused_circuits(void);
-circuit_t *circuit_launch_new(uint8_t purpose);
+circuit_t *circuit_launch_new(uint8_t purpose, const char *exit_nickname);
 void circuit_increment_failure_count(void);
 void circuit_reset_failure_count(void);
 void circuit_n_conn_open(connection_t *or_conn);
@@ -916,7 +916,7 @@
                              char *key_out,
                              int key_out_len);
 
-cpath_build_state_t *onion_new_cpath_build_state(void);
+cpath_build_state_t *onion_new_cpath_build_state(const char *exit_nickname);
 
 /********************************* router.c ***************************/
 

Index: rendservice.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendservice.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- rendservice.c	1 Apr 2004 03:43:54 -0000	1.4
+++ rendservice.c	1 Apr 2004 03:44:49 -0000	1.5
@@ -363,7 +363,7 @@
 
     // for each intro point,
     {
-      circ = circuit_launch_new(CIRCUIT_PURPOSE_S_ESTABLISH_INTRO);
+      //circ = circuit_launch_new(CIRCUIT_PURPOSE_S_ESTABLISH_INTRO, intro->nickname);
       // tell circ which hidden service this is about
     }