Merge remote-tracking branch 'ffmancera/github/bug23459'

This commit is contained in:
Nick Mathewson 2017-12-11 09:53:39 -05:00
commit 7803b19c43
4 changed files with 39 additions and 8 deletions

4
changes/ticket23459 Normal file
View File

@ -0,0 +1,4 @@
o Code simplification and refactoring (circuit rendezvous):
- Split get rendezvous circuit on client side on two different functions.
One that returns only established circuits and another that returns all
kinds of circuits. Closes ticket 23459.

View File

@ -431,6 +431,37 @@ hs_circuitmap_get_rend_circ_client_side(const uint8_t *cookie)
{ {
origin_circuit_t *circ = NULL; origin_circuit_t *circ = NULL;
circ = hs_circuitmap_get_established_rend_circ_client_side(cookie);
if (circ) {
return circ;
}
circ = hs_circuitmap_get_origin_circuit(HS_TOKEN_REND_CLIENT_SIDE,
REND_TOKEN_LEN, cookie,
CIRCUIT_PURPOSE_C_ESTABLISH_REND);
return circ;
}
/* Public function: Return client-side established rendezvous circuit with
* rendezvous <b>cookie</b>. It will look for circuits with the following
* purposes:
*
* a) CIRCUIT_PURPOSE_C_REND_READY: Established rend circuit (received
* RENDEZVOUS_ESTABLISHED). Waiting for RENDEZVOUS2 from service, and for
* INTRODUCE_ACK from intro point.
*
* b) CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED: Established rend circuit and
* introduce circuit acked. Waiting for RENDEZVOUS2 from service.
*
* c) CIRCUIT_PURPOSE_C_REND_JOINED: Established rend circuit and received
* RENDEZVOUS2 from service.
*
* Return NULL if no such circuit is found in the circuitmap. */
origin_circuit_t *
hs_circuitmap_get_established_rend_circ_client_side(const uint8_t *cookie)
{
origin_circuit_t *circ = NULL;
circ = hs_circuitmap_get_origin_circuit(HS_TOKEN_REND_CLIENT_SIDE, circ = hs_circuitmap_get_origin_circuit(HS_TOKEN_REND_CLIENT_SIDE,
REND_TOKEN_LEN, cookie, REND_TOKEN_LEN, cookie,
CIRCUIT_PURPOSE_C_REND_READY); CIRCUIT_PURPOSE_C_REND_READY);
@ -448,13 +479,6 @@ hs_circuitmap_get_rend_circ_client_side(const uint8_t *cookie)
circ = hs_circuitmap_get_origin_circuit(HS_TOKEN_REND_CLIENT_SIDE, circ = hs_circuitmap_get_origin_circuit(HS_TOKEN_REND_CLIENT_SIDE,
REND_TOKEN_LEN, cookie, REND_TOKEN_LEN, cookie,
CIRCUIT_PURPOSE_C_REND_JOINED); CIRCUIT_PURPOSE_C_REND_JOINED);
if (circ) {
return circ;
}
circ = hs_circuitmap_get_origin_circuit(HS_TOKEN_REND_CLIENT_SIDE,
REND_TOKEN_LEN, cookie,
CIRCUIT_PURPOSE_C_ESTABLISH_REND);
return circ; return circ;
} }

View File

@ -45,6 +45,8 @@ struct origin_circuit_t *
hs_circuitmap_get_rend_circ_service_side(const uint8_t *cookie); hs_circuitmap_get_rend_circ_service_side(const uint8_t *cookie);
struct origin_circuit_t * struct origin_circuit_t *
hs_circuitmap_get_rend_circ_client_side(const uint8_t *cookie); hs_circuitmap_get_rend_circ_client_side(const uint8_t *cookie);
struct origin_circuit_t *
hs_circuitmap_get_established_rend_circ_client_side(const uint8_t *cookie);
void hs_circuitmap_register_intro_circ_v2_service_side( void hs_circuitmap_register_intro_circ_v2_service_side(
struct origin_circuit_t *circ, struct origin_circuit_t *circ,

View File

@ -945,7 +945,8 @@ handle_introduce_ack_success(origin_circuit_t *intro_circ)
/* Get the rendezvous circuit for this rendezvous cookie. */ /* Get the rendezvous circuit for this rendezvous cookie. */
uint8_t *rendezvous_cookie = intro_circ->hs_ident->rendezvous_cookie; uint8_t *rendezvous_cookie = intro_circ->hs_ident->rendezvous_cookie;
rend_circ = hs_circuitmap_get_rend_circ_client_side(rendezvous_cookie); rend_circ =
hs_circuitmap_get_established_rend_circ_client_side(rendezvous_cookie);
if (rend_circ == NULL) { if (rend_circ == NULL) {
log_warn(LD_REND, "Can't find any rendezvous circuit. Stopping"); log_warn(LD_REND, "Can't find any rendezvous circuit. Stopping");
goto end; goto end;