summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2003-09-12 06:50:21 +0000
committerRoger Dingledine <arma@torproject.org>2003-09-12 06:50:21 +0000
commit1738af96202ebf0a9830893d627c5913a04984a3 (patch)
tree33ce05d345016ba886ac01f735a29e22941d9152
parentb1078b7a3cdf805b60ceba934fc70610c3a923f4 (diff)
downloadtor-1738af96202ebf0a9830893d627c5913a04984a3.tar.gz
tor-1738af96202ebf0a9830893d627c5913a04984a3.zip
tls works between routers now too
things are still a bit shaky svn:r450
-rw-r--r--src/or/connection.c17
-rw-r--r--src/or/connection_or.c4
-rw-r--r--src/or/or.h2
3 files changed, 16 insertions, 7 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index 2a51264e24..572ae888be 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -33,6 +33,11 @@ char *conn_state_to_string[][15] = {
"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 @@ char *conn_state_to_string[][15] = {
"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 @@ connection_t *connection_new(int type) {
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 @@ static int connection_init_accepted_conn(connection_t *conn) {
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 @@ static int connection_init_accepted_conn(connection_t *conn) {
}
#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 @@ static int connection_tls_continue_handshake(connection_t *conn) {
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;
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 832330d93d..f9bd2f8481 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -86,7 +86,7 @@ int connection_or_finished_flushing(connection_t *conn) {
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 @@ connection_t *connection_or_connect(routerinfo_t *router) {
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) ||
diff --git a/src/or/or.h b/src/or/or.h
index 7f05ec3611..f5a32a94f6 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -583,7 +583,7 @@ int connection_create_listener(struct sockaddr_in *bindaddr, int type);
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);