aboutsummaryrefslogtreecommitdiff
path: root/src/or/connection_or.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-11-03 18:33:07 +0000
committerNick Mathewson <nickm@torproject.org>2004-11-03 18:33:07 +0000
commit451f8b50452ae44c4319cfe55c666a45b9994e9f (patch)
treed88f565d8f7f74253af9d2a721978737b157782a /src/or/connection_or.c
parent86ba00290b4e1f7095c1d34c46ac5b61273953be (diff)
downloadtor-451f8b50452ae44c4319cfe55c666a45b9994e9f.tar.gz
tor-451f8b50452ae44c4319cfe55c666a45b9994e9f.zip
- Implement all of control interface except authentication, setconfig,
and actually making the sockets. - Make sure that identity-based nicknames start with $. - Use new string_join interface. svn:r2661
Diffstat (limited to 'src/or/connection_or.c')
-rw-r--r--src/or/connection_or.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 02cb4fa23b..2852ad599e 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -140,8 +140,9 @@ connection_or_init_conn_from_address(connection_t *conn,
if (n) {
conn->nickname = tor_strdup(n);
} else {
- conn->nickname = tor_malloc(HEX_DIGEST_LEN+1);
- base16_encode(conn->nickname, HEX_DIGEST_LEN+1,
+ conn->nickname = tor_malloc(HEX_DIGEST_LEN+2);
+ conn->nickname[0] = '$';
+ base16_encode(conn->nickname+1, HEX_DIGEST_LEN+1,
conn->identity_digest, DIGEST_LEN);
}
tor_free(conn->address);
@@ -223,10 +224,12 @@ connection_t *connection_or_connect(uint32_t addr, uint16_t port,
/* set up conn so it's got all the data we need to remember */
connection_or_init_conn_from_address(conn, addr, port, id_digest);
conn->state = OR_CONN_STATE_CONNECTING;
+ control_event_or_conn_status(conn, OR_CONN_EVENT_LAUNCHED);
switch(connection_connect(conn, conn->address, addr, port)) {
case -1:
router_mark_as_down(conn->identity_digest);
+ control_event_or_conn_status(conn, OR_CONN_EVENT_FAILED);
connection_free(conn);
return NULL;
case 0:
@@ -376,6 +379,7 @@ connection_tls_finish_handshake(connection_t *conn) {
log_fn(options.DirPort ? LOG_WARN : LOG_INFO,
"Other side (%s:%d) is '%s', but we tried to connect to '%s'",
conn->address, conn->port, nickname, conn->nickname);
+ control_event_or_conn_status(conn, OR_CONN_EVENT_FAILED);
return -1;
}
} else {
@@ -393,6 +397,7 @@ connection_tls_finish_handshake(connection_t *conn) {
circuit_n_conn_done(conn, 1); /* send the pending creates, if any. */
/* Note the success */
rep_hist_note_connect_succeeded(conn->identity_digest, time(NULL));
+ control_event_or_conn_status(conn, OR_CONN_EVENT_CONNECTED);
return 0;
}