summaryrefslogtreecommitdiff
path: root/src/or/hs_circuitmap.c
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2017-07-25 12:05:02 +0300
committerDavid Goulet <dgoulet@torproject.org>2017-08-24 13:03:28 -0400
commit3152c583af052571cbcd058bb1569f2ad821ec42 (patch)
tree284fed4306acb11786458ecbdc6a6e08256e7b35 /src/or/hs_circuitmap.c
parente67f8623f95082341c06c9c70ef664ed7b186483 (diff)
downloadtor-3152c583af052571cbcd058bb1569f2ad821ec42.tar.gz
tor-3152c583af052571cbcd058bb1569f2ad821ec42.zip
prop224: Add client-side rend circuit support to HS circuitmap
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/hs_circuitmap.c')
-rw-r--r--src/or/hs_circuitmap.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/src/or/hs_circuitmap.c b/src/or/hs_circuitmap.c
index ea66fb5194..f235ecc82d 100644
--- a/src/or/hs_circuitmap.c
+++ b/src/or/hs_circuitmap.c
@@ -5,8 +5,10 @@
* \file hs_circuitmap.c
*
* \brief Hidden service circuitmap: A hash table that maps binary tokens to
- * introduction and rendezvous circuits; it's used both by relays acting as
- * intro points and rendezvous points, and also by hidden services themselves.
+ * introduction and rendezvous circuits; it's used:
+ * (a) by relays acting as intro points and rendezvous points
+ * (b) by hidden services to find intro and rend circuits and
+ * (c) by HS clients to find rendezvous circuits.
**/
#define HS_CIRCUITMAP_PRIVATE
@@ -404,6 +406,29 @@ hs_circuitmap_get_rend_circ_service_side(const uint8_t *cookie)
return circ;
}
+/* Public function: Return client-side rendezvous circuit with rendezvous
+ * <b>cookie</b>. It will first lookup for the CIRCUIT_PURPOSE_C_REND_READY
+ * purpose and then try for CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED.
+ *
+ * Return NULL if no such circuit is found in the circuitmap. */
+origin_circuit_t *
+hs_circuitmap_get_rend_circ_client_side(const uint8_t *cookie)
+{
+ origin_circuit_t *circ = NULL;
+
+ circ = hs_circuitmap_get_origin_circuit(HS_TOKEN_REND_CLIENT_SIDE,
+ REND_TOKEN_LEN, cookie,
+ CIRCUIT_PURPOSE_C_REND_READY);
+ if (circ) {
+ return circ;
+ }
+
+ circ = hs_circuitmap_get_origin_circuit(HS_TOKEN_REND_CLIENT_SIDE,
+ REND_TOKEN_LEN, cookie,
+ CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED);
+ return circ;
+}
+
/**** Public servide-side setters: */
/* Public function: Register v2 intro circuit with key <b>digest</b> to the
@@ -439,6 +464,22 @@ hs_circuitmap_register_rend_circ_service_side(origin_circuit_t *circ,
REND_TOKEN_LEN, cookie);
}
+/* Public function: Register rendezvous circuit with key <b>cookie</b> to the
+ * client-side circuitmap. */
+void
+hs_circuitmap_register_rend_circ_client_side(origin_circuit_t *or_circ,
+ const uint8_t *cookie)
+{
+ circuit_t *circ = TO_CIRCUIT(or_circ);
+ { /* Basic circ purpose sanity checking */
+ tor_assert_nonfatal(circ->purpose == CIRCUIT_PURPOSE_C_REND_READY ||
+ circ->purpose == CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED);
+ }
+
+ hs_circuitmap_register_circuit(circ, HS_TOKEN_REND_CLIENT_SIDE,
+ REND_TOKEN_LEN, cookie);
+}
+
/**** Misc public functions: */
/** Public function: Remove this circuit from the HS circuitmap. Clear its HS