aboutsummaryrefslogtreecommitdiff
path: root/src/or/connection_or.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-10-13 20:05:57 +0000
committerNick Mathewson <nickm@torproject.org>2004-10-13 20:05:57 +0000
commite0cce8fba8dcefa8745a4ba768f911c09d9d7573 (patch)
tree289c0e8cd459725788e1234bae539b69b9a9ce28 /src/or/connection_or.c
parent30dd1c87a5ac1ebe7756bb48f7c94cb7f20de1da (diff)
downloadtor-e0cce8fba8dcefa8745a4ba768f911c09d9d7573.tar
tor-e0cce8fba8dcefa8745a4ba768f911c09d9d7573.tar.gz
Unify tests for "did I originate this nonopen OR connection?"
svn:r2468
Diffstat (limited to 'src/or/connection_or.c')
-rw-r--r--src/or/connection_or.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index acff78b18..ccbb3f54c 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -300,10 +300,17 @@ int connection_tls_continue_handshake(connection_t *conn) {
return 0;
}
-static int digest_is_zero(const char *id) {
- char ZERO_DIGEST[DIGEST_LEN];
- memset(ZERO_DIGEST, 0, DIGEST_LEN);
- return !memcmp(ZERO_DIGEST, id, DIGEST_LEN);
+static char ZERO_DIGEST[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
+
+int connection_or_nonopen_was_started_here(connection_t *conn)
+{
+ tor_assert(sizeof(ZERO_DIGEST) == DIGEST_LEN);
+ tor_assert(conn->type == CONN_TYPE_OR);
+
+ if (!memcmp(ZERO_DIGEST, conn->identity_digest, DIGEST_LEN))
+ return 0;
+ else
+ return 1;
}
/** The tls handshake is finished.
@@ -371,7 +378,7 @@ connection_tls_finish_handshake(connection_t *conn) {
return -1;
}
- if (!digest_is_zero(conn->identity_digest)) {
+ if (connection_or_nonopen_was_started_here(conn)) {
/* I initiated this connection. */
if (strcasecmp(conn->nickname, nickname)) {
log_fn(options.DirPort ? LOG_WARN : LOG_INFO,