arti-client: Create an HsClientConnector
This commit is contained in:
parent
a2aa701eb6
commit
3d33ad7fdf
|
@ -185,6 +185,7 @@ dependencies = [
|
|||
"tor-dirmgr",
|
||||
"tor-error",
|
||||
"tor-guardmgr",
|
||||
"tor-hsclient",
|
||||
"tor-hscrypto",
|
||||
"tor-llcrypto",
|
||||
"tor-netdir",
|
||||
|
|
|
@ -67,7 +67,7 @@ experimental = [
|
|||
experimental-api = []
|
||||
dirfilter = ["tor-dirmgr/dirfilter"]
|
||||
error_detail = []
|
||||
onion-client = ["tor-hscrypto"]
|
||||
onion-client = ["tor-hsclient", "tor-hscrypto"]
|
||||
|
||||
[dependencies]
|
||||
cfg-if = "1.0.0"
|
||||
|
@ -96,6 +96,7 @@ tor-dirmgr = { path = "../tor-dirmgr", version = "0.9.2", default-features = fal
|
|||
] }
|
||||
tor-error = { path = "../tor-error", version = "0.4.1" }
|
||||
tor-guardmgr = { path = "../tor-guardmgr", version = "0.8.2" }
|
||||
tor-hsclient = { path = "../tor-hsclient", version = "0.1.1", optional = true }
|
||||
tor-hscrypto = { path = "../tor-hscrypto", version = "0.1.1", optional = true }
|
||||
tor-llcrypto = { path = "../tor-llcrypto", version = "0.4.2" }
|
||||
tor-netdir = { path = "../tor-netdir", version = "0.8.0" }
|
||||
|
|
|
@ -17,6 +17,8 @@ use tor_dirmgr::bridgedesc::BridgeDescMgr;
|
|||
use tor_dirmgr::{DirMgrStore, Timeliness};
|
||||
use tor_error::{internal, Bug, ErrorReport};
|
||||
use tor_guardmgr::GuardMgr;
|
||||
#[cfg(feature = "onion-client")]
|
||||
use tor_hsclient::HsClientConnector;
|
||||
use tor_netdir::{params::NetParameters, NetDirProvider};
|
||||
use tor_persist::{FsStateMgr, StateMgr};
|
||||
use tor_proto::circuit::ClientCirc;
|
||||
|
@ -92,6 +94,10 @@ pub struct TorClient<R: Runtime> {
|
|||
/// Pluggable transport manager.
|
||||
#[cfg(feature = "pt-client")]
|
||||
pt_mgr: Arc<tor_ptmgr::PtMgr<R>>,
|
||||
/// HS client connector
|
||||
#[allow(dead_code)] // TODO HS remove
|
||||
#[cfg(feature = "onion-client")]
|
||||
hsclient: HsClientConnector<R>,
|
||||
/// Guard manager
|
||||
#[cfg_attr(not(feature = "bridge-client"), allow(dead_code))]
|
||||
guardmgr: GuardMgr<R>,
|
||||
|
@ -521,6 +527,13 @@ impl<R: Runtime> TorClient<R> {
|
|||
#[cfg(feature = "bridge-client")]
|
||||
let bridge_desc_mgr = Arc::new(Mutex::new(None));
|
||||
|
||||
#[cfg(feature = "onion-client")]
|
||||
let hsclient = HsClientConnector::new(
|
||||
runtime.clone(),
|
||||
circmgr.clone(),
|
||||
dirmgr.clone().upcast_arc(),
|
||||
)?;
|
||||
|
||||
runtime
|
||||
.spawn(tasks_monitor_dormant(
|
||||
dormant_recv,
|
||||
|
@ -558,6 +571,8 @@ impl<R: Runtime> TorClient<R> {
|
|||
bridge_desc_mgr,
|
||||
#[cfg(feature = "pt-client")]
|
||||
pt_mgr,
|
||||
#[cfg(feature = "onion-client")]
|
||||
hsclient,
|
||||
guardmgr,
|
||||
statemgr,
|
||||
addrcfg: Arc::new(addr_cfg.into()),
|
||||
|
|
|
@ -139,6 +139,11 @@ enum ErrorDetail {
|
|||
#[error("Error setting up the persistent state manager")]
|
||||
StateMgrSetup(#[source] tor_persist::Error),
|
||||
|
||||
/// Error setting up the hidden service client connector.
|
||||
#[error("Error setting up the hidden service client connector")]
|
||||
#[cfg(feature = "onion-client")]
|
||||
HsClientConnectorSetup(#[from] tor_hsclient::StartupError),
|
||||
|
||||
/// Failed to obtain exit circuit
|
||||
#[error("Failed to obtain exit circuit for ports {exit_ports}")]
|
||||
ObtainExitCircuit {
|
||||
|
@ -316,6 +321,8 @@ impl tor_error::HasKind for ErrorDetail {
|
|||
E::CircMgrSetup(e) => e.kind(),
|
||||
E::DirMgrSetup(e) => e.kind(),
|
||||
E::StateMgrSetup(e) => e.kind(),
|
||||
#[cfg(feature = "onion-client")]
|
||||
E::HsClientConnectorSetup(e) => e.kind(),
|
||||
E::DirMgrBootstrap(e) => e.kind(),
|
||||
#[cfg(feature = "pt-client")]
|
||||
E::PluggableTransport(e) => e.kind(),
|
||||
|
|
Loading…
Reference in New Issue