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

[or-cvs] refactor; start adding debugging logs to midpoint rend stuff



Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv1780/src/or

Modified Files:
	circuit.c command.c connection_edge.c or.h rendcommon.c 
	rendmid.c rendservice.c 
Log Message:
refactor; start adding debugging logs to midpoint rend stuff

Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.170
retrieving revision 1.171
diff -u -d -r1.170 -r1.171
--- circuit.c	2 Apr 2004 22:23:15 -0000	1.170
+++ circuit.c	2 Apr 2004 23:30:53 -0000	1.171
@@ -347,7 +347,7 @@
       continue;
     if (circ->purpose != purpose)
       continue;
-    if (!memcmp(circ->rend_service, servid, REND_COOKIE_LEN))
+    if (!memcmp(circ->rend_service, servid, CRYPTO_SHA1_DIGEST_LEN))
       return circ;
   }
   return NULL;

Index: command.c
===================================================================
RCS file: /home/or/cvsroot/src/or/command.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- command.c	30 Mar 2004 19:52:42 -0000	1.55
+++ command.c	2 Apr 2004 23:30:53 -0000	1.56
@@ -103,7 +103,7 @@
 
   circ = circuit_new(cell->circ_id, conn);
   circ->state = CIRCUIT_STATE_ONIONSKIN_PENDING;
-  circ->purpose = CIRCUIT_PURPOSE_INTERMEDIATE;
+  circ->purpose = CIRCUIT_PURPOSE_OR;
 
   memcpy(circ->onionskin, cell->payload, ONIONSKIN_CHALLENGE_LEN);
 

Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -d -r1.126 -r1.127
--- connection_edge.c	2 Apr 2004 22:23:15 -0000	1.126
+++ connection_edge.c	2 Apr 2004 23:30:53 -0000	1.127
@@ -792,6 +792,7 @@
       desired_circuit_purpose = CIRCUIT_PURPOSE_C_INTRODUCING;
       break;
     default:
+      log_fn(LOG_ERR, "Got unexpected purpose: %d", conn->purpose);
       assert(0); /* never reached */
   }
 

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.282
retrieving revision 1.283
diff -u -d -r1.282 -r1.283
--- or.h	2 Apr 2004 23:01:00 -0000	1.282
+++ or.h	2 Apr 2004 23:30:53 -0000	1.283
@@ -201,7 +201,7 @@
 
 #define _CIRCUIT_PURPOSE_MIN 1
 /* these circuits were initiated elsewhere */
-#define CIRCUIT_PURPOSE_INTERMEDIATE 1 /* normal circuit, at OR. */
+#define CIRCUIT_PURPOSE_OR 1 /* normal circuit, at OR. */
 #define CIRCUIT_PURPOSE_INTRO_POINT 2 /* At OR, from Bob, waiting for intro from Alices */
 #define CIRCUIT_PURPOSE_REND_POINT_WAITING 3 /* At OR, from Alice, waiting for Bob */
 #define CIRCUIT_PURPOSE_REND_ESTABLISHED 4 /* At OR, both circuits have this purpose */

Index: rendcommon.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendcommon.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- rendcommon.c	2 Apr 2004 22:23:15 -0000	1.7
+++ rendcommon.c	2 Apr 2004 23:30:53 -0000	1.8
@@ -169,7 +169,9 @@
   if(strlen(query) != REND_SERVICE_ID_LEN)
     return 0;
 
-  /* XXXX also check for bad chars. */
+  if (strspn(query, BASE32_CHARS) != REND_SERVICE_ID_LEN)
+    return 0;
+
   return 1;
 }
 

Index: rendmid.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendmid.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- rendmid.c	2 Apr 2004 21:56:52 -0000	1.2
+++ rendmid.c	2 Apr 2004 23:30:53 -0000	1.3
@@ -16,9 +16,12 @@
   char pk_digest[20];
   int asn1len;
   circuit_t *c;
+  char hexid[9];
 
-  if (circ->purpose != CIRCUIT_PURPOSE_INTERMEDIATE) {
-    log_fn(LOG_WARN, "Rejecting ESTABLISH_INTRO on non-intermediate circuit");
+  log_fn(LOG_INFO, "Received an ESTABLISH_INTRO request on circuit %d", circ->p_circ_id);
+
+  if (circ->purpose != CIRCUIT_PURPOSE_OR || circ->n_conn) {
+    log_fn(LOG_WARN, "Rejecting ESTABLISH_INTRO on non-OR or non-edge circuit");
     goto err;
   }
   if (request_len < 22)
@@ -60,10 +63,13 @@
     goto err;
   }
 
+  hex_encode(pk_digest, 4, hexid);
+
   /* Close any other intro circuits with the same pk. */
   c = NULL;
   while ((c = circuit_get_next_by_service_and_purpose(
                                 c,pk_digest,CIRCUIT_PURPOSE_INTRO_POINT))) {
+    log_fn(LOG_INFO, "Replacing old circuit %d for service %s", c->p_circ_id, hexid);
     circuit_mark_for_close(c);
   }
 
@@ -71,6 +77,9 @@
   circ->purpose = CIRCUIT_PURPOSE_INTRO_POINT;
   memcpy(circ->rend_service, pk_digest, 20);
 
+  log_fn(LOG_INFO, "Established introduction point on circuit %d for service %s",
+         circ->p_circ_id, hexid);
+
   return 0;
  truncated:
   log_fn(LOG_WARN, "Rejecting truncated ESTABLISH_INTRO cell");
@@ -123,8 +132,8 @@
 int
 rend_mid_establish_rendezvous(circuit_t *circ, char *request, int request_len)
 {
-  if (circ->purpose != CIRCUIT_PURPOSE_INTERMEDIATE) {
-    log_fn(LOG_WARN, "Tried to establish rendezvous on non-intermediate circuit");
+  if (circ->purpose != CIRCUIT_PURPOSE_OR || circ->n_conn) {
+    log_fn(LOG_WARN, "Tried to establish rendezvous on non-OR or non-edge circuit");
     goto err;
   }
 
@@ -155,8 +164,8 @@
 {
   circuit_t *rend_circ;
 
-  if (circ->purpose != CIRCUIT_PURPOSE_INTERMEDIATE) {
-    log_fn(LOG_WARN, "Tried to complete rendezvous on non-intermediate circuit");
+  if (circ->purpose != CIRCUIT_PURPOSE_OR || circ->n_conn) {
+    log_fn(LOG_WARN, "Tried to complete rendezvous on non-OR or non-edge circuit");
     goto err;
   }
 

Index: rendservice.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendservice.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- rendservice.c	2 Apr 2004 23:04:10 -0000	1.12
+++ rendservice.c	2 Apr 2004 23:30:54 -0000	1.13
@@ -166,7 +166,6 @@
   return result;
 }
 
-
 /* Set up rend_service_list, based on the values of HiddenServiceDir and
  * HiddenServicePort in 'options'.  Return 0 on success and -1 on
  * failure.