parent
f2d6d7976d
commit
386d422a1b
|
@ -4639,6 +4639,7 @@ dependencies = [
|
|||
"postage",
|
||||
"rand 0.8.5",
|
||||
"rand_core 0.6.4",
|
||||
"retry-error",
|
||||
"safelog",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
|
|
@ -35,6 +35,7 @@ once_cell = "1"
|
|||
postage = { version = "0.5.0", default-features = false, features = ["futures-traits"] }
|
||||
rand = "0.8.5"
|
||||
rand_core = "0.6.2"
|
||||
retry-error = { version = "0.5.0", path = "../retry-error" }
|
||||
safelog = { path = "../safelog", version = "0.3.3" }
|
||||
serde = { version = "1.0.103", features = ["derive"] }
|
||||
thiserror = "1"
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use futures::{stream::BoxStream, StreamExt as _};
|
||||
use retry_error::RetryError;
|
||||
use tor_cell::relaycell::{
|
||||
hs::intro_payload::{IntroduceHandshakePayload, OnionKey},
|
||||
msg::{Introduce2, Rendezvous1},
|
||||
|
@ -59,9 +60,9 @@ pub(crate) enum EstablishSessionError {
|
|||
/// Got an onion key with an unrecognized type (not ntor).
|
||||
#[error("Received an unsupported type of onion key")]
|
||||
UnsupportedOnionKey,
|
||||
/// Encountered an error while trying to build a circuit to the rendezvous point.
|
||||
/// Unable to build a circuit to the rendezvous point.
|
||||
#[error("Could not establish circuit to rendezvous point")]
|
||||
RendCirc(#[source] tor_circmgr::Error),
|
||||
RendCirc(#[source] RetryError<tor_circmgr::Error>),
|
||||
/// Encountered a failure while trying to add a virtual hop to the circuit.
|
||||
#[error("Could not add virtual hop to circuit")]
|
||||
VirtualHop(#[source] tor_proto::Error),
|
||||
|
@ -226,13 +227,30 @@ impl IntroRequest {
|
|||
)
|
||||
};
|
||||
|
||||
let max_n_attempts = netdir.params().hs_service_rendezvous_failures_max;
|
||||
let mut circuit = None;
|
||||
let mut retry_err: RetryError<tor_circmgr::Error> =
|
||||
RetryError::in_attempt_to("Establish a circuit to a rendezvous point");
|
||||
|
||||
// Open circuit to rendezvous point.
|
||||
let circuit = hs_pool
|
||||
.get_or_launch_specific(&netdir, HsCircKind::SvcRend, rend_point)
|
||||
for _attempt in 1..=max_n_attempts.into() {
|
||||
match hs_pool
|
||||
.get_or_launch_specific(&netdir, HsCircKind::SvcRend, rend_point.clone())
|
||||
.await
|
||||
.map_err(E::RendCirc)?;
|
||||
// TODO HSS: Maybe we should retry a couple of time if the failure is not
|
||||
// the fault of the rend_point?
|
||||
{
|
||||
Ok(circ) => {
|
||||
circuit = Some(circ);
|
||||
break;
|
||||
}
|
||||
Err(e) => {
|
||||
retry_err.push(e);
|
||||
// Note that we do not sleep on errors: if there is any
|
||||
// error that will be solved by waiting, it would probably
|
||||
// require waiting too long to satisfy the client.
|
||||
}
|
||||
}
|
||||
}
|
||||
let circuit = circuit.ok_or_else(|| E::RendCirc(retry_err))?;
|
||||
|
||||
// We'll need parameters to extend the virtual hop.
|
||||
let params = circparameters_from_netparameters(netdir.params());
|
||||
|
|
Loading…
Reference in New Issue