summaryrefslogtreecommitdiff
path: root/src/or/command.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/command.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/command.c')
-rw-r--r--src/or/command.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/or/command.c b/src/or/command.c
index 14dd4994d1..1e3027581c 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -118,8 +118,9 @@ command_process_cell(cell_t *cell, or_connection_t *conn)
#define PROCESS_CELL(tp, cl, cn) command_process_ ## tp ## _cell(cl, cn)
#endif
- /* Reject all but VERSIONS when handshaking. */
- if (handshaking && cell->command != CELL_VERSIONS)
+ /* Reject all but VERSIONS and NETINFO when handshaking. */
+ if (handshaking && cell->command != CELL_VERSIONS &&
+ cell->command != CELL_NETINFO)
return;
switch (cell->command) {
@@ -476,7 +477,8 @@ command_process_versions_cell(var_cell_t *cell, or_connection_t *conn)
conn->link_proto = highest_supported_version;
conn->handshake_state->received_versions = 1;
- // log_notice(LD_OR, "Negotiated version %d", highest_supported_version);
+ log_info(LD_OR, "Negotiated version %d with %s",
+ highest_supported_version, safe_str(conn->_base.address));
if (highest_supported_version >= 2) {
if (connection_or_send_netinfo(conn) < 0) {
@@ -500,6 +502,7 @@ command_process_netinfo_cell(cell_t *cell, or_connection_t *conn)
const char *cp, *end;
uint8_t n_other_addrs;
time_t now = time(NULL);
+
if (conn->link_proto < 2) {
log_fn(LOG_PROTOCOL_WARN, LD_OR,
"Received a NETINFO cell on %s connection; dropping.",
@@ -562,5 +565,16 @@ command_process_netinfo_cell(cell_t *cell, or_connection_t *conn)
}
conn->handshake_state->received_netinfo = 1;
+
+ if (conn->handshake_state->apparently_canonical) {
+ conn->is_canonical = 1;
+ }
+ if (connection_or_act_on_netinfo(conn)<0 ||
+ connection_or_set_state_open(conn)<0)
+ connection_mark_for_close(TO_CONN(conn));
+
+ log_info(LD_OR, "Got good NETINFO cell from %s",
+ safe_str(conn->_base.address));
+ assert_connection_ok(TO_CONN(conn),time(NULL));
}