[or-cvs] tls works between routers now too

Roger Dingledine arma at seul.org
Fri Sep 12 06:50:24 UTC 2003


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

Modified Files:
	connection.c connection_or.c or.h 
Log Message:
tls works between routers now too
things are still a bit shaky


Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -d -r1.86 -r1.87
--- connection.c	12 Sep 2003 06:20:36 -0000	1.86
+++ connection.c	12 Sep 2003 06:50:21 -0000	1.87
@@ -33,6 +33,11 @@
     "close",             /* 2 */
     "close_wait" },      /* 3 */
   { "ready" }, /* or listener, 0 */
+#ifdef USE_TLS
+  { "connect()ing",                 /* 0 */
+    "handshaking",                  /* 1 */
+    "open" },                       /* 2 */
+#else
   { "connecting (as OP)",       /* or, 0 */
     "sending keys (as OP)",         /* 1 */
     "connecting (as client)",       /* 2 */
@@ -43,6 +48,7 @@
     "sending auth (as server)",     /* 7 */
     "waiting for nonce (as server)",/* 8 */
     "open" },                       /* 9 */
+#endif
   { "waiting for dest info",     /* exit, 0 */
     "connecting",                      /* 1 */
     "open" },                          /* 2 */
@@ -88,7 +94,7 @@
      buf_new(&conn->outbuf, &conn->outbuflen, &conn->outbuf_datalen) < 0)
     return NULL;
 
-  conn->receiver_bucket = 10240; /* should be enough to do the handshake */
+  conn->receiver_bucket = 50000; /* should be enough to do the handshake */
   conn->bandwidth = conn->receiver_bucket / 10; /* give it a default */
 
   conn->timestamp_created = now.tv_sec;
@@ -254,7 +260,7 @@
   switch(conn->type) {
     case CONN_TYPE_OR:
 #ifdef USE_TLS
-      if(connection_tls_start_handshake(conn) < 0)
+      if(connection_tls_start_handshake(conn, 1) < 0)
         return -1;
 #else
       conn->state = OR_CONN_STATE_SERVER_AUTH_WAIT;
@@ -271,14 +277,15 @@
 }
 
 #ifdef USE_TLS
-int connection_tls_start_handshake(connection_t *conn) {
+int connection_tls_start_handshake(connection_t *conn, int receiving) {
   conn->state = OR_CONN_STATE_HANDSHAKING;
-  conn->tls = tor_tls_new(conn->s, options.OnionRouter);
+  conn->tls = tor_tls_new(conn->s, receiving);
   if(!conn->tls) {
     log_fn(LOG_ERR,"tor_tls_new failed. Closing.");
     return -1;
   }
   connection_start_reading(conn);
+  log_fn(LOG_DEBUG,"starting the handshake");
   if(connection_tls_continue_handshake(conn) < 0)
     return -1;
   return 0;
@@ -294,8 +301,10 @@
      return connection_tls_finish_handshake(conn);
     case TOR_TLS_WANTWRITE:
       connection_start_writing(conn);
+      log_fn(LOG_DEBUG,"wanted write");
       return 0;
     case TOR_TLS_WANTREAD: /* handshaking conns are *always* reading */
+      log_fn(LOG_DEBUG,"wanted read");
       return 0;
   }
   return 0;

Index: connection_or.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_or.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- connection_or.c	12 Sep 2003 06:20:36 -0000	1.46
+++ connection_or.c	12 Sep 2003 06:50:21 -0000	1.47
@@ -86,7 +86,7 @@
           conn->address,conn->port);
 
 #ifdef USE_TLS
-      if(connection_tls_start_handshake(conn) < 0)
+      if(connection_tls_start_handshake(conn, 0) < 0)
         return -1;
 #else
       if(options.OnionRouter)
@@ -205,7 +205,7 @@
       router->address, router->or_port);
 
 #ifdef USE_TLS
-  if(connection_tls_start_handshake(conn) >= 0)
+  if(connection_tls_start_handshake(conn, 0) >= 0)
     return conn;
 #else
   if((options.OnionRouter && or_handshake_client_send_auth(conn) >= 0) ||

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -d -r1.120 -r1.121
--- or.h	11 Sep 2003 22:19:48 -0000	1.120
+++ or.h	12 Sep 2003 06:50:21 -0000	1.121
@@ -583,7 +583,7 @@
 
 int connection_handle_listener_read(connection_t *conn, int new_type);
 
-int connection_tls_start_handshake(connection_t *conn);
+int connection_tls_start_handshake(connection_t *conn, int receiving);
 
 /* start all connections that should be up but aren't */
 int retry_all_connections(uint16_t or_listenport, uint16_t ap_listenport, uint16_t dir_listenport);



More information about the tor-commits mailing list