[or-cvs] alice chooses her rendezvous node from all running routers

Roger Dingledine arma at seul.org
Thu Apr 1 20:33:31 UTC 2004


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

Modified Files:
	circuit.c config.c connection_edge.c onion.c or.h 
Log Message:
alice chooses her rendezvous node from all running routers
and she can set preferences in her options


Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.166
retrieving revision 1.167
diff -u -d -r1.166 -r1.167
--- circuit.c	1 Apr 2004 20:05:56 -0000	1.166
+++ circuit.c	1 Apr 2004 20:33:28 -0000	1.167
@@ -1057,9 +1057,6 @@
 /* Launch a new circuit and return a pointer to it. Return NULL if you failed. */
 circuit_t *circuit_launch_new(uint8_t purpose, const char *exit_nickname) {
 
-  if(!(options.SocksPort||options.RunTesting)) /* no need for circuits. */
-    return NULL;
-
   if(n_circuit_failures > 5) { /* too many failed circs in a row. don't try. */
 //    log_fn(LOG_INFO,"%d failures so far, not trying.",n_circuit_failures);
     return NULL;
@@ -1086,11 +1083,11 @@
 
   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(exit_nickname);
+  circ->build_state = onion_new_cpath_build_state(purpose, exit_nickname);
   circ->purpose = purpose;
 
   if (! circ->build_state) {
-    log_fn(LOG_INFO,"Generating cpath length failed.");
+    log_fn(LOG_INFO,"Generating cpath failed.");
     circuit_mark_for_close(circ);
     return NULL;
   }

Index: config.c
===================================================================
RCS file: /home/or/cvsroot/src/or/config.c,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -d -r1.103 -r1.104
--- config.c	31 Mar 2004 21:35:23 -0000	1.103
+++ config.c	1 Apr 2004 20:33:28 -0000	1.104
@@ -205,6 +205,8 @@
     config_compare(list, "RouterFile",     CONFIG_TYPE_STRING, &options->RouterFile) ||
     config_compare(list, "RunAsDaemon",    CONFIG_TYPE_BOOL, &options->RunAsDaemon) ||
     config_compare(list, "RecommendedVersions",CONFIG_TYPE_STRING, &options->RecommendedVersions) ||
+    config_compare(list, "RendNodes",      CONFIG_TYPE_STRING, &options->RendNodes) ||
+    config_compare(list, "RendExcludeNodes",CONFIG_TYPE_STRING, &options->RendExcludeNodes) ||
 
     config_compare(list, "SocksPort",      CONFIG_TYPE_INT, &options->SocksPort) ||
     config_compare(list, "SocksBindAddress",CONFIG_TYPE_STRING,&options->SocksBindAddress) ||
@@ -419,6 +421,8 @@
   tor_free(options->ExitNodes);
   tor_free(options->EntryNodes);
   tor_free(options->ExcludeNodes);
+  tor_free(options->RendNodes);
+  tor_free(options->RendExcludeNodes);
   tor_free(options->ExitPolicy);
   tor_free(options->SocksBindAddress);
   tor_free(options->ORBindAddress);
@@ -436,6 +440,8 @@
   options->ExitNodes = tor_strdup("");
   options->EntryNodes = tor_strdup("");
   options->ExcludeNodes = tor_strdup("");
+  options->RendNodes = tor_strdup("");
+  options->RendExcludeNodes = tor_strdup("");
   options->ExitPolicy = tor_strdup("");
   options->SocksBindAddress = tor_strdup("127.0.0.1");
   options->ORBindAddress = tor_strdup("0.0.0.0");

Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -d -r1.124 -r1.125
--- connection_edge.c	1 Apr 2004 03:44:49 -0000	1.124
+++ connection_edge.c	1 Apr 2004 20:33:28 -0000	1.125
@@ -201,6 +201,15 @@
   return 0;
 }
 
+/* Make a relay cell out of 'relay_command' and 'payload', and
+ * send it onto the open circuit 'circ'. If it's a control cell,
+ * set fromconn to NULL, else it's the stream that's sending the
+ * relay cell. Use cpath_layer NULL if you're responding to the OP;
+ * If it's an outgoing cell it must specify the destination hop.
+ *
+ * If you can't send the cell, mark the circuit for close and
+ * return -1. Else return 0.
+ */
 int connection_edge_send_command(connection_t *fromconn, circuit_t *circ,
                                  int relay_command, void *payload,
                                  int payload_len, crypt_path_t *cpath_layer) {
@@ -738,8 +747,13 @@
 
     /* see if we already have it cached */
     if (rend_cache_lookup(socks->address, &descp, &desc_len) == 1) {
-      /* then pick and launch a rendezvous circuit */
-      /* go into some other state */
+      if(0){ //if a circuit already exists to this place, use it
+
+      } else {
+        /* go into some other state maybe? */
+        /* then launch a rendezvous circuit */
+        circuit_launch_new(CIRCUIT_PURPOSE_C_ESTABLISH_REND, NULL);
+      }
     } else {
       /* initiate a dir hidserv desc lookup */
       /* go into a state where you'll be notified of the answer */

Index: onion.c
===================================================================
RCS file: /home/or/cvsroot/src/or/onion.c,v
retrieving revision 1.135
retrieving revision 1.136
diff -u -d -r1.135 -r1.136
--- onion.c	1 Apr 2004 03:44:49 -0000	1.135
+++ onion.c	1 Apr 2004 20:33:28 -0000	1.136
@@ -4,6 +4,11 @@
 
 #include "or.h"
 
+/* prototypes for smartlist operations from routerlist.h
+ * they're here to prevent precedence issues with the .h files
+ */
+void router_add_running_routers_to_smartlist(smartlist_t *sl);
+
 extern or_options_t options; /* command-line and config-file options */
 
 static int count_acceptable_routers(routerinfo_t **rarray, int rarray_len);
@@ -220,7 +225,34 @@
   return routelen;
 }
 
-static routerinfo_t *choose_good_exit_server(routerlist_t *dir)
+static routerinfo_t *choose_good_exit_server_rend(routerlist_t *dir)
+{
+  smartlist_t *sl, *excludednodes;
+  routerinfo_t *choice;
+
+  excludednodes = smartlist_create();
+  add_nickname_list_to_smartlist(excludednodes,options.RendExcludeNodes);
+
+  /* try the nodes in RendNodes first */
+  sl = smartlist_create();
+  add_nickname_list_to_smartlist(sl,options.RendNodes);
+  smartlist_subtract(sl,excludednodes);
+  choice = smartlist_choose(sl);
+  smartlist_free(sl);
+  if(!choice) {
+    sl = smartlist_create();
+    router_add_running_routers_to_smartlist(sl);
+    smartlist_subtract(sl,excludednodes);
+    choice = smartlist_choose(sl);
+    smartlist_free(sl);
+  }
+  smartlist_free(excludednodes);
+  if(!choice)
+    log_fn(LOG_WARN,"No available nodes when trying to choose rendezvous point. Failing.");
+  return choice;
+}
+
+static routerinfo_t *choose_good_exit_server_general(routerlist_t *dir)
 {
   int *n_supported;
   int i, j;
@@ -347,7 +379,16 @@
   return NULL;
 }
 
-cpath_build_state_t *onion_new_cpath_build_state(const char *exit_nickname) {
+static routerinfo_t *choose_good_exit_server(uint8_t purpose, routerlist_t *dir)
+{
+  if(purpose == CIRCUIT_PURPOSE_C_GENERAL)
+    return choose_good_exit_server_general(dir);
+  else
+    return choose_good_exit_server_rend(dir);
+}
+
+cpath_build_state_t *onion_new_cpath_build_state(uint8_t purpose,
+                                                 const char *exit_nickname) {
   routerlist_t *rl;
   int r;
   cpath_build_state_t *info;
@@ -357,13 +398,13 @@
   r = new_route_len(options.PathlenCoinWeight, rl->routers, rl->n_routers);
   if (r < 0)
     return NULL;
-  info = tor_malloc(sizeof(cpath_build_state_t));
+  info = tor_malloc_zero(sizeof(cpath_build_state_t));
   info->desired_path_len = r;
   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);
+    exit = choose_good_exit_server(purpose, rl);
     if(!exit) {
       tor_free(info);
       return NULL;
@@ -407,11 +448,6 @@
   return num;
 }
 
-/* prototypes for smartlist operations from routerlist.h
- * they're here to prevent precedence issues with the .h files
- */
-void router_add_running_routers_to_smartlist(smartlist_t *sl);
-
 static void remove_twins_from_smartlist(smartlist_t *sl, routerinfo_t *twin) {
   int i;
   routerinfo_t *r;

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.275
retrieving revision 1.276
diff -u -d -r1.275 -r1.276
--- or.h	1 Apr 2004 20:05:57 -0000	1.275
+++ or.h	1 Apr 2004 20:33:29 -0000	1.276
@@ -533,7 +533,7 @@
   uint8_t state;
   uint8_t purpose;
 
-  /* The field rend_sevice:
+  /* The field rend_service:
    *  holds hash of location-hidden service's PK if purpose is INTRO_POINT
    *     or S_ESTABLISH_INTRO or S_RENDEZVOUSING;
    *  holds y portion of y.onion (zero-padded) if purpose is C_INTRODUCING or
@@ -570,9 +570,14 @@
   char *Nickname;
   char *Address;
   char *PidFile;
+
   char *ExitNodes;
   char *EntryNodes;
   char *ExcludeNodes;
+
+  char *RendNodes;
+  char *RendExcludeNodes;
+
   char *ExitPolicy;
   char *SocksBindAddress;
   char *ORBindAddress;
@@ -919,7 +924,8 @@
                              char *key_out,
                              int key_out_len);
 
-cpath_build_state_t *onion_new_cpath_build_state(const char *exit_nickname);
+cpath_build_state_t *onion_new_cpath_build_state(uint8_t purpose,
+                                                 const char *exit_nickname);
 
 /********************************* router.c ***************************/
 



More information about the tor-commits mailing list