summaryrefslogtreecommitdiff
path: root/src/or/connection_or.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-02-08 23:41:29 +0000
committerNick Mathewson <nickm@torproject.org>2008-02-08 23:41:29 +0000
commit8f7fcdd64e1e155f22ed9b4916e4eacc30a3b341 (patch)
tree86c4b5a5ad680ac9a4c9235d161a6195f8dcc559 /src/or/connection_or.c
parent272d37deb3ed7e3dc1c713666aaac3b914d3ae33 (diff)
downloadtor-8f7fcdd64e1e155f22ed9b4916e4eacc30a3b341.tar.gz
tor-8f7fcdd64e1e155f22ed9b4916e4eacc30a3b341.zip
r17991@catbus: nickm | 2008-02-08 18:41:26 -0500
More protocol negotiation work. Make the negotiation actually complete and set the state to open. Fix a crash bug that occured when we forcibly stopped the connection from writing. svn:r13434
Diffstat (limited to 'src/or/connection_or.c')
-rw-r--r--src/or/connection_or.c44
1 files changed, 8 insertions, 36 deletions
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index de6f58cd0c..f2bd54a494 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -597,12 +597,6 @@ connection_or_tls_renegotiated_cb(tor_tls_t *tls, void *_conn)
/* XXXX_TLS double-check that this verifies certificates. */
connection_mark_for_close(TO_CONN(conn));
}
-
-#if 0
- /* XXXX_TLS this happens later, right? */
- connection_or_init_conn_from_address(conn, conn->_base.addr,
- conn->_base.port, id_digest, 0);
-#endif
}
/** Move forward with the tls handshake. If it finishes, hand
@@ -806,31 +800,6 @@ connection_or_check_valid_tls_handshake(or_connection_t *conn,
return 0;
}
-#if 0
-/** DOCDOC */
-int
-connection_or_finish_or_handshake(or_connection_t *conn)
-{
- char id_digest[DIGEST_LEN];
- tor_assert(conn);
- tor_assert(conn->handshake_state);
- tor_assert(conn->link_proto >= 2);
- tor_assert(conn->handshake_state->received_versions != 0);
- tor_assert(conn->handshake_state->received_netinfo != 0);
- tor_assert(conn->handshake_state->received_certs != 0);
-
- if (connection_or_check_valid_tls_handshake(conn,
- conn->handshake_state->started_here,
- id_digest) < 0)
- return -1;
- connection_or_init_conn_from_address(conn, conn->_base.addr,
- conn->_base.port, id_digest, 0);
- if (connection_or_act_on_netinfo(conn)<0)
- return -1;
- return connection_or_set_state_open(conn);
-}
-#endif
-
/** The tls handshake is finished.
*
* Make sure we are happy with the person we just handshaked with.
@@ -868,6 +837,10 @@ connection_tls_finish_handshake(or_connection_t *conn)
conn->_base.state = OR_CONN_STATE_OR_HANDSHAKING;
if (connection_init_or_handshake_state(conn, started_here) < 0)
return -1;
+ if (!started_here) {
+ connection_or_init_conn_from_address(conn,conn->_base.addr,
+ conn->_base.port, digest_rcvd, 0);
+ }
return connection_or_send_versions(conn);
}
}
@@ -917,7 +890,7 @@ connection_or_set_state_open(or_connection_t *conn)
or_handshake_state_free(conn->handshake_state);
conn->handshake_state = NULL;
}
- connection_watch_events(TO_CONN(conn), EV_READ);
+ connection_start_reading(TO_CONN(conn));
circuit_n_conn_done(conn, 1); /* send the pending creates, if any. */
return 0;
@@ -1117,6 +1090,7 @@ int
connection_or_act_on_netinfo(or_connection_t *conn)
{
long delta;
+ /*XXXX020 merge this into handle_netinfo.*/
if (!conn->handshake_state)
return -1;
@@ -1142,12 +1116,10 @@ connection_or_act_on_netinfo(or_connection_t *conn)
delta, conn->_base.address, conn->_base.port);
}
- /* XXX020 possibly, learn my address from my_apparent_addr */
-
- if (conn->handshake_state->apparently_canonical) {
+ if (conn->handshake_state->apparently_canonical)
conn->is_canonical = 1;
- }
+ /* XXX020 possibly, learn my address from my_apparent_addr */
return 0;
}