[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] test: Introduce hs_client_note_connection_attempt_succeeded().



commit 9ff5613a340f220a202d3f0332f091d812068881
Author: George Kadianakis <desnacked@xxxxxxxxxx>
Date:   Tue May 2 16:22:00 2017 +0300

    test: Introduce hs_client_note_connection_attempt_succeeded().
    
    This commit paves the way for the e2e circuit unittests.
    
    Add a stub for the prop224 equivalent of rend_client_note_connection_attempt_ended().
    
    That function was needed for tests, since the legacy function would get
    called when we attach streams and our client-side tests would crash with
    assert failures on rend_data.
    
    This also introduces hs_client.[ch] to the codebase.
---
 src/or/circuituse.c |  4 ++--
 src/or/hs_client.c  | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 src/or/hs_client.h  | 16 ++++++++++++++++
 src/or/include.am   |  2 ++
 4 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index 288b49e..a3b7066 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -42,6 +42,7 @@
 #include "control.h"
 #include "entrynodes.h"
 #include "hs_common.h"
+#include "hs_client.h"
 #include "hs_ident.h"
 #include "nodelist.h"
 #include "networkstatus.h"
@@ -2374,8 +2375,7 @@ link_apconn_to_circ(entry_connection_t *apconn, origin_circuit_t *circ,
     /* We are attaching a stream to a rendezvous circuit.  That means
      * that an attempt to connect to a hidden service just
      * succeeded.  Tell rendclient.c. */
-    rend_client_note_connection_attempt_ended(
-                    ENTRY_TO_EDGE_CONN(apconn)->rend_data);
+    hs_client_note_connection_attempt_succeeded(ENTRY_TO_EDGE_CONN(apconn));
   }
 
   if (cpath) { /* we were given one; use it */
diff --git a/src/or/hs_client.c b/src/or/hs_client.c
new file mode 100644
index 0000000..12fcf3a
--- /dev/null
+++ b/src/or/hs_client.c
@@ -0,0 +1,47 @@
+/* Copyright (c) 2016-2017, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file hs_service.c
+ * \brief Implement next generation hidden service client functionality
+ **/
+
+#include "or.h"
+#include "hs_circuit.h"
+#include "connection_edge.h"
+#include "rendclient.h"
+
+#include "hs_client.h"
+
+/** A prop224 v3 HS circuit successfully connected to the hidden
+ *  service. Update the stream state at <b>hs_conn_ident</b> appropriately. */
+static void
+hs_client_attempt_succeeded(const hs_ident_edge_conn_t *hs_conn_ident)
+{
+  (void) hs_conn_ident;
+
+  /* TODO: When implementing client side */
+  return;
+}
+
+/** A circuit just finished connecting to a hidden service that the stream
+ *  <b>conn</b> has been waiting for. Let the HS subsystem know about this. */
+void
+hs_client_note_connection_attempt_succeeded(const edge_connection_t *conn)
+{
+  tor_assert(connection_edge_is_rendezvous_stream(conn));
+
+  if (BUG(conn->rend_data && conn->hs_ident)) {
+    log_warn(LD_BUG, "Stream had both rend_data and hs_ident..."
+             "Prioritizing hs_ident");
+  }
+
+  if (conn->hs_ident) { /* It's v3: pass it to the prop224 handler */
+    hs_client_attempt_succeeded(conn->hs_ident);
+    return;
+  } else if (conn->rend_data) { /* It's v2: pass it to the legacy handler */
+    rend_client_note_connection_attempt_ended(conn->rend_data);
+    return;
+  }
+}
+
diff --git a/src/or/hs_client.h b/src/or/hs_client.h
new file mode 100644
index 0000000..4f28937
--- /dev/null
+++ b/src/or/hs_client.h
@@ -0,0 +1,16 @@
+/* Copyright (c) 2017, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file hs_client.h
+ * \brief Header file containing client data for the HS subsytem.
+ **/
+
+#ifndef TOR_HS_CLIENT_H
+#define TOR_HS_CLIENT_H
+
+void hs_client_note_connection_attempt_succeeded(
+                                       const edge_connection_t *conn);
+
+#endif /* TOR_HS_CLIENT_H */
+
diff --git a/src/or/include.am b/src/or/include.am
index 18868e4..2f9f1a9 100644
--- a/src/or/include.am
+++ b/src/or/include.am
@@ -59,6 +59,7 @@ LIBTOR_A_SOURCES = \
 	src/or/hs_intropoint.c				\
 	src/or/hs_ntor.c				\
 	src/or/hs_service.c				\
+	src/or/hs_client.c				\
 	src/or/entrynodes.c				\
 	src/or/ext_orport.c				\
 	src/or/hibernate.c				\
@@ -190,6 +191,7 @@ ORHEADERS = \
 	src/or/hs_circuitmap.h          \
 	src/or/hs_ntor.h                \
 	src/or/hs_service.h             \
+	src/or/hs_client.h              \
 	src/or/keypin.h					\
 	src/or/main.h					\
 	src/or/microdesc.h				\



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits