aboutsummaryrefslogtreecommitdiff
path: root/src/or/rendclient.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2017-07-27 12:37:52 -0400
committerDavid Goulet <dgoulet@torproject.org>2017-08-24 13:03:28 -0400
commit88b843608accd10af6d12c53531950566ded5ef9 (patch)
treee36d92ecc5c0617351343addd432cfe0678e9193 /src/or/rendclient.c
parent88f64eee68c972845131c8e372af067d8bb37cd1 (diff)
downloadtor-88b843608accd10af6d12c53531950566ded5ef9.tar.gz
tor-88b843608accd10af6d12c53531950566ded5ef9.zip
prop224: Move and refactor rend_client_reextend_intro_circuit()
This moves it to hs_client.c so it can be used by both system (legacy and prop224). For now, only the legacy system uses it. Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/rendclient.c')
-rw-r--r--src/or/rendclient.c45
1 files changed, 3 insertions, 42 deletions
diff --git a/src/or/rendclient.c b/src/or/rendclient.c
index cb7d99bed3..d983dea7ed 100644
--- a/src/or/rendclient.c
+++ b/src/or/rendclient.c
@@ -18,6 +18,7 @@
#include "directory.h"
#include "hs_common.h"
#include "hs_circuit.h"
+#include "hs_client.h"
#include "main.h"
#include "networkstatus.h"
#include "nodelist.h"
@@ -89,46 +90,6 @@ rend_client_send_establish_rendezvous(origin_circuit_t *circ)
return 0;
}
-/** Extend the introduction circuit <b>circ</b> to another valid
- * introduction point for the hidden service it is trying to connect
- * to, or mark it and launch a new circuit if we can't extend it.
- * Return 0 on success or possible success. Return -1 and mark the
- * introduction circuit for close on permanent failure.
- *
- * On failure, the caller is responsible for marking the associated
- * rendezvous circuit for close. */
-static int
-rend_client_reextend_intro_circuit(origin_circuit_t *circ)
-{
- extend_info_t *extend_info;
- int result;
- extend_info = rend_client_get_random_intro(circ->rend_data);
- if (!extend_info) {
- log_warn(LD_REND,
- "No usable introduction points left for %s. Closing.",
- safe_str_client(rend_data_get_address(circ->rend_data)));
- circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_INTERNAL);
- return -1;
- }
- // XXX: should we not re-extend if hs_circ_has_timed_out?
- if (circ->remaining_relay_early_cells) {
- log_info(LD_REND,
- "Re-extending circ %u, this time to %s.",
- (unsigned)circ->base_.n_circ_id,
- safe_str_client(extend_info_describe(extend_info)));
- result = circuit_extend_to_new_exit(circ, extend_info);
- } else {
- log_info(LD_REND,
- "Closing intro circ %u (out of RELAY_EARLY cells).",
- (unsigned)circ->base_.n_circ_id);
- circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_FINISHED);
- /* connection_ap_handshake_attach_circuit will launch a new intro circ. */
- result = 0;
- }
- extend_info_free(extend_info);
- return result;
-}
-
/** Called when we're trying to connect an ap conn; sends an INTRODUCE1 cell
* down introcirc if possible.
*/
@@ -202,7 +163,7 @@ rend_client_send_introduction(origin_circuit_t *introcirc,
introcirc->build_state->chosen_exit)),
smartlist_len(entry->parsed->intro_nodes));
- if (rend_client_reextend_intro_circuit(introcirc)) {
+ if (hs_client_reextend_intro_circuit(introcirc)) {
status = -2;
goto perm_err;
} else {
@@ -437,7 +398,7 @@ rend_client_introduction_acked(origin_circuit_t *circ,
INTRO_POINT_FAILURE_GENERIC)>0) {
/* There are introduction points left. Re-extend the circuit to
* another intro point and try again. */
- int result = rend_client_reextend_intro_circuit(circ);
+ int result = hs_client_reextend_intro_circuit(circ);
/* XXXX If that call failed, should we close the rend circuit,
* too? */
return result;