[or-cvs] more progress on alice"s side

Roger Dingledine arma at seul.org
Sat Apr 3 03:06:09 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 connection_edge.c or.h rendclient.c 
Log Message:
more progress on alice's side


Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.178
retrieving revision 1.179
diff -u -d -r1.178 -r1.179
--- circuit.c	3 Apr 2004 02:40:29 -0000	1.178
+++ circuit.c	3 Apr 2004 03:06:06 -0000	1.179
@@ -1069,6 +1069,9 @@
       /* at Bob, connecting to rend point */
       rend_service_rendezvous_is_ready(circ);
       break;
+    default:
+      log_fn(LOG_ERR,"unhandled purpose %d",circ->purpose);
+      assert(0);
   }
 }
 

Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -d -r1.131 -r1.132
--- connection_edge.c	3 Apr 2004 01:59:53 -0000	1.131
+++ connection_edge.c	3 Apr 2004 03:06:06 -0000	1.132
@@ -763,6 +763,53 @@
   return 0;
 }
 
+/* find an open circ that we're happy with: return 1. if there isn't
+ * one, launch one and return 0. if it will never work, return -1.
+ * write the found or launched circ into *circp.
+ */
+static int
+get_open_circ_or_launch(connection_t *conn,
+                        uint8_t desired_circuit_purpose,
+                        circuit_t **circp) {
+  circuit_t *circ;
+  uint32_t addr;
+
+  assert(conn);
+  assert(circp);
+
+  circ = circuit_get_newest(conn, 1, desired_circuit_purpose);
+
+  if(circ) {
+    *circp = circ;
+    return 1; /* we're happy */
+  }
+
+  log_fn(LOG_INFO,"No safe circuit (purpose %d) ready for edge connection; delaying.",
+         desired_circuit_purpose);
+
+  if(conn->purpose == AP_PURPOSE_GENERAL) {
+    addr = client_dns_lookup_entry(conn->socks_request->address);
+    if(router_exit_policy_all_routers_reject(addr, conn->socks_request->port)) {
+      log_fn(LOG_WARN,"No Tor server exists that allows exit to %s:%d. Rejecting.",
+             conn->socks_request->address, conn->socks_request->port);
+      return -1;
+    }
+  }
+  if(!circuit_get_newest(conn, 0, desired_circuit_purpose)) {
+    /* is one already on the way? */
+    circ = circuit_launch_new(desired_circuit_purpose, NULL);
+    /* depending on purpose, store stuff into circ */
+    if(circ &&
+       (desired_circuit_purpose == CIRCUIT_PURPOSE_C_GENERAL ||
+        desired_circuit_purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND)) {
+      /* then write the service_id into circ */
+      strcpy(circ->rend_query, conn->rend_query);
+    }
+  }
+  *circp = circ;
+  return 0;
+}
+
 /* Try to find a safe live circuit for CONN_TYPE_AP connection conn. If
  * we don't find one: if conn cannot be handled by any known nodes,
  * warn and return -1 (conn needs to die);
@@ -771,9 +818,9 @@
  * right next step, and return 1.
  */
 int connection_ap_handshake_attach_circuit(connection_t *conn) {
-  circuit_t *circ;
-  uint32_t addr;
+  circuit_t *circ=NULL;
   uint8_t desired_circuit_purpose;
+  int retval;
 
   assert(conn);
   assert(conn->type == CONN_TYPE_AP);
@@ -799,34 +846,9 @@
   }
 
   /* find the circuit that we should use, if there is one. */
-  circ = circuit_get_newest(conn, 1, desired_circuit_purpose);
-
-  if(!circ) {
-
-    log_fn(LOG_INFO,"No safe circuit (purpose %d) ready for edge connection; delaying.",
-           desired_circuit_purpose);
-
-    if(conn->purpose == AP_PURPOSE_GENERAL) {
-      addr = client_dns_lookup_entry(conn->socks_request->address);
-      if(router_exit_policy_all_routers_reject(addr, conn->socks_request->port)) {
-        log_fn(LOG_WARN,"No Tor server exists that allows exit to %s:%d. Rejecting.",
-               conn->socks_request->address, conn->socks_request->port);
-        return -1;
-      }
-    }
-    if(!circuit_get_newest(conn, 0, desired_circuit_purpose)) {
-      /* is one already on the way? */
-      circ = circuit_launch_new(desired_circuit_purpose, NULL);
-      /* depending on purpose, store stuff into circ */
-      if(circ &&
-         (desired_circuit_purpose == CIRCUIT_PURPOSE_C_GENERAL ||
-          desired_circuit_purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND)) {
-        /* then write the service_id into circ */
-        strcpy(circ->rend_query, conn->rend_query);
-      }
-    }
-    return 0;
-  }
+  retval = get_open_circ_or_launch(conn, desired_circuit_purpose, &circ);
+  if(retval < 1)
+    return retval;
 
   /* We have found a suitable circuit for our conn. Hurray. */
 

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.290
retrieving revision 1.291
diff -u -d -r1.290 -r1.291
--- or.h	3 Apr 2004 02:40:30 -0000	1.290
+++ or.h	3 Apr 2004 03:06:06 -0000	1.291
@@ -1054,6 +1054,7 @@
 
 void rend_cache_init(void);
 void rend_cache_clean(void);
+int rend_valid_service_id(char *query);
 int rend_cache_lookup(char *query, const char **desc, int *desc_len);
 int rend_cache_store(char *desc, int desc_len);
 

Index: rendclient.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendclient.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- rendclient.c	3 Apr 2004 01:59:53 -0000	1.5
+++ rendclient.c	3 Apr 2004 03:06:06 -0000	1.6
@@ -16,9 +16,22 @@
 void
 rend_client_rendcirc_is_ready(connection_t *apconn, circuit_t *circ)
 {
+  circuit_t *introcirc;
+
+  assert(apconn->purpose == AP_PURPOSE_RENDPOINT_WAIT);
+  assert(circ->purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND);
+  assert(circ->cpath);
 
+  log_fn(LOG_INFO,"rendcirc is ready");
 
-  log_fn(LOG_WARN,"rendcirc is ready");
+  /* XXX generate a rendezvous cookie, store it in circ */
+  /* store rendcirc in apconn */
+
+  apconn->purpose = AP_PURPOSE_INTROPOINT_WAIT;
+  if (connection_ap_handshake_attach_circuit(apconn) < 0) {
+    log_fn(LOG_WARN,"failed to start intro point. Closing conn.");
+    connection_mark_for_close(apconn,0);
+  }
 }
 
 /* bob sent us a rendezvous cell, join the circs. */



More information about the tor-commits mailing list