Browse Source

Changes missed in previous commits

Steven Engler 4 years ago
parent
commit
28d542ca9c
2 changed files with 24 additions and 18 deletions
  1. 23 18
      src/core/or/channeltls.c
  2. 1 0
      src/core/or/safe_connection.h

+ 23 - 18
src/core/or/channeltls.c

@@ -1530,24 +1530,22 @@ channel_tls_process_versions_cell(var_cell_t *cell, channel_tls_t *chan)
 
   rep_hist_note_negotiated_link_proto(highest_supported_version, started_here);
 
-  chan->conn->link_proto = highest_supported_version;
-  chan->conn->handshake_state->received_versions = 1;
+  uint16_t link_protocol = highest_supported_version;
 
-  tor_assert(TO_CONN(chan->conn)->safe_conn != NULL);
-  safe_or_connection_set_link_protocol(TO_SAFE_OR_CONN(TO_CONN(chan->conn)->safe_conn),
-                                       chan->conn->link_proto);
-
-  if (chan->conn->link_proto == 2) {
-    log_info(LD_OR,
-             "Negotiated version %d with %s:%d; sending NETINFO.",
-             highest_supported_version,
-             safe_str_client(chan->conn->base_.address),
-             chan->conn->base_.port);
-
-    if (connection_or_send_netinfo(chan->conn) < 0) {
-      connection_or_close_for_error(chan->conn, 0);
-      return;
-    }
+  if (link_protocol == 2) {
+    log_warn(LD_OR, "We don't support a link protocol of 2");
+    connection_or_close_for_error(chan->conn, 0);
+    return;
+    //log_info(LD_OR,
+    //         "Negotiated version %d with %s:%d; sending NETINFO.",
+    //         highest_supported_version,
+    //         safe_str_client(chan->conn->base_.address),
+    //         chan->conn->base_.port);
+
+    //if (connection_or_send_netinfo(chan->conn) < 0) {
+    //  connection_or_close_for_error(chan->conn, 0);
+    //  return;
+    //}
   } else {
     const int send_versions = !started_here;
     /* If we want to authenticate, send a CERTS cell */
@@ -1559,7 +1557,7 @@ channel_tls_process_versions_cell(var_cell_t *cell, channel_tls_t *chan)
     const int send_netinfo = !started_here;
     const int send_any =
       send_versions || send_certs || send_chall || send_netinfo;
-    tor_assert(chan->conn->link_proto >= 3);
+    tor_assert(link_protocol >= 3);
 
     log_info(LD_OR,
              "Negotiated version %d with %s:%d; %s%s%s%s%s",
@@ -1587,6 +1585,13 @@ channel_tls_process_versions_cell(var_cell_t *cell, channel_tls_t *chan)
       }
     }
 
+    chan->conn->link_proto = link_protocol;
+    chan->conn->handshake_state->received_versions = 1;
+
+    event_data_t event_data = { .u16 = chan->conn->link_proto };
+    event_source_publish(TO_CONN(chan->conn)->event_source,
+                         or_conn_link_protocol_version_ev, event_data, NULL);
+
     /* We set this after sending the versions cell. */
     /*XXXXX symbolic const.*/
     TLS_CHAN_TO_BASE(chan)->wide_circ_ids =

+ 1 - 0
src/core/or/safe_connection.h

@@ -74,6 +74,7 @@ typedef struct safe_connection_t {
 
   event_source_t *event_source;
   event_listener_t *event_listener;
+  bool care_about_modified;
 } safe_connection_t;
 
 typedef struct safe_or_connection_t {