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

[or-cvs] Patch: when extending to an unknown router, compare identit...



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

Modified Files:
	connection_or.c 
Log Message:
Patch: when extending to an unknown router, compare identity to expected identity; not nickname-to-expected identity.

Index: connection_or.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection_or.c,v
retrieving revision 1.162
retrieving revision 1.163
diff -u -d -r1.162 -r1.163
--- connection_or.c	22 Mar 2005 18:43:24 -0000	1.162
+++ connection_or.c	31 Mar 2005 23:30:13 -0000	1.163
@@ -495,7 +495,18 @@
 
   if (connection_or_nonopen_was_started_here(conn)) {
     /* I initiated this connection. */
-    if (strcasecmp(conn->nickname, nickname)) {
+    if (conn->nickname[0] == '$') {
+      /* I was aiming for a particular digest. Did I get it? */
+      char d[HEX_DIGEST_LEN+1];
+      base16_encode(d, HEX_DIGEST_LEN+1, digest_rcvd, DIGEST_LEN);
+      if (strcasecmp(d,conn->nickname+1)) {
+        log_fn(LOG_WARN, "Identity key not as expected for router at %s:%d: wanted %s but got %s",
+               conn->address, conn->port, conn->nickname, d);
+        control_event_or_conn_status(conn, OR_CONN_EVENT_FAILED);
+        return -1;
+      }
+    } else if (strcasecmp(conn->nickname, nickname)) {
+      /* I was aiming for a nickname.  Did I get it? */
       log_fn(authdir_mode(options) ? LOG_WARN : LOG_INFO,
              "Other side (%s:%d) is '%s', but we tried to connect to '%s'",
              conn->address, conn->port, nickname, conn->nickname);