parent
f2d6d7976d
commit
386d422a1b
|
@ -4639,6 +4639,7 @@ dependencies = [
|
||||||
"postage",
|
"postage",
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"rand_core 0.6.4",
|
"rand_core 0.6.4",
|
||||||
|
"retry-error",
|
||||||
"safelog",
|
"safelog",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
|
|
@ -35,6 +35,7 @@ once_cell = "1"
|
||||||
postage = { version = "0.5.0", default-features = false, features = ["futures-traits"] }
|
postage = { version = "0.5.0", default-features = false, features = ["futures-traits"] }
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
rand_core = "0.6.2"
|
rand_core = "0.6.2"
|
||||||
|
retry-error = { version = "0.5.0", path = "../retry-error" }
|
||||||
safelog = { path = "../safelog", version = "0.3.3" }
|
safelog = { path = "../safelog", version = "0.3.3" }
|
||||||
serde = { version = "1.0.103", features = ["derive"] }
|
serde = { version = "1.0.103", features = ["derive"] }
|
||||||
thiserror = "1"
|
thiserror = "1"
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use futures::{stream::BoxStream, StreamExt as _};
|
use futures::{stream::BoxStream, StreamExt as _};
|
||||||
|
use retry_error::RetryError;
|
||||||
use tor_cell::relaycell::{
|
use tor_cell::relaycell::{
|
||||||
hs::intro_payload::{IntroduceHandshakePayload, OnionKey},
|
hs::intro_payload::{IntroduceHandshakePayload, OnionKey},
|
||||||
msg::{Introduce2, Rendezvous1},
|
msg::{Introduce2, Rendezvous1},
|
||||||
|
@ -59,9 +60,9 @@ pub(crate) enum EstablishSessionError {
|
||||||
/// Got an onion key with an unrecognized type (not ntor).
|
/// Got an onion key with an unrecognized type (not ntor).
|
||||||
#[error("Received an unsupported type of onion key")]
|
#[error("Received an unsupported type of onion key")]
|
||||||
UnsupportedOnionKey,
|
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")]
|
#[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.
|
/// Encountered a failure while trying to add a virtual hop to the circuit.
|
||||||
#[error("Could not add virtual hop to circuit")]
|
#[error("Could not add virtual hop to circuit")]
|
||||||
VirtualHop(#[source] tor_proto::Error),
|
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.
|
// Open circuit to rendezvous point.
|
||||||
let circuit = hs_pool
|
for _attempt in 1..=max_n_attempts.into() {
|
||||||
.get_or_launch_specific(&netdir, HsCircKind::SvcRend, rend_point)
|
match hs_pool
|
||||||
.await
|
.get_or_launch_specific(&netdir, HsCircKind::SvcRend, rend_point.clone())
|
||||||
.map_err(E::RendCirc)?;
|
.await
|
||||||
// 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.
|
// We'll need parameters to extend the virtual hop.
|
||||||
let params = circparameters_from_netparameters(netdir.params());
|
let params = circparameters_from_netparameters(netdir.params());
|
||||||
|
|
Loading…
Reference in New Issue