"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 */
"sending auth (as server)", /* 7 */
"waiting for nonce (as server)",/* 8 */
"open" }, /* 9 */
+#endif
{ "waiting for dest info", /* exit, 0 */
"connecting", /* 1 */
"open" }, /* 2 */
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;
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;
}
#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;
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;
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)
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) ||
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);