Commit 25b8522a authored by Mike Perry's avatar Mike Perry
Browse files

Simplify checks for vg-lite.

parent 60e27a7b
Pipeline #5760 failed with stage
in 13 minutes and 3 seconds
...@@ -2255,22 +2255,9 @@ middle_node_must_be_vanguard(const or_options_t *options, ...@@ -2255,22 +2255,9 @@ middle_node_must_be_vanguard(const or_options_t *options,
return 0; return 0;
} }
/* If HSLayer2Nodes is set and we are picking an L2 node, we always want it /* If we are a hidden service circuit, always use either vanguards-lite
* to be a vanguard */ * or HSLayer2Nodes for 2nd hop. */
if (options->HSLayer2Nodes && cur_len == 1) { if (cur_len == 1) {
return 1;
}
/* If we are picking an L2 node as a client or pre-built vanguards circ,
* we do want a vanguard */
if ((circuit_purpose_is_hs_client(purpose) ||
purpose == CIRCUIT_PURPOSE_HS_VANGUARDS) && cur_len == 1) {
return 1;
}
/* Let's also do layer2 vanguards for services. Not enough for long-lived
* services, but will be enough for eg onionshare. */
if (circuit_purpose_is_hs_service(purpose) && cur_len == 1) {
return 1; return 1;
} }
......
...@@ -2006,31 +2006,12 @@ circuit_is_hs_v3(const circuit_t *circ) ...@@ -2006,31 +2006,12 @@ circuit_is_hs_v3(const circuit_t *circ)
int int
circuit_should_use_vanguards(uint8_t purpose) circuit_should_use_vanguards(uint8_t purpose)
{ {
const or_options_t *options = get_options(); /* All hidden service circuits use either vanguards or
* vanguards-lite. */
/* Only hidden service circuits use vanguards */ if (circuit_purpose_is_hidden_service(purpose))
if (!circuit_purpose_is_hidden_service(purpose))
return 0;
/* Client-side purpose should use vanguards-lite */
if (circuit_purpose_is_hs_client(purpose)) {
return 1;
}
/* Service-side purpose should use vanguards-lite */
if (circuit_purpose_is_hs_service(purpose)) {
return 1;
}
/* Circuits already with HS_VANGUARDS purpose use vanguards */
if (circuit_purpose_is_hs_vanguards(purpose)) {
return 1;
}
/* Pinned middles are effectively vanguards */
if (options->HSLayer2Nodes || options->HSLayer3Nodes)
return 1; return 1;
/* Everything else is a normal circuit */
return 0; return 0;
} }
...@@ -2068,13 +2049,11 @@ circuit_should_cannibalize_to_build(uint8_t purpose_to_build, ...@@ -2068,13 +2049,11 @@ circuit_should_cannibalize_to_build(uint8_t purpose_to_build,
return 0; return 0;
} }
/* For vanguards, the server-side intro circ is not cannibalized /* The server-side intro circ is not cannibalized because it only
* because we pre-build 4 hop HS circuits, and it only needs a 3 hop * needs a 3 hop circuit. It is also long-lived, so it is more
* circuit. It is also long-lived, so it is more important that * important that it have lower latency than get built fast.
* it have lower latency than get built fast.
*/ */
if (circuit_should_use_vanguards(purpose_to_build) && if (purpose_to_build == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO) {
purpose_to_build == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO) {
return 0; return 0;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment