From 9b6be7eaa77f16be33cdebc75e6a68ee67a913b1 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 28 Mar 2023 12:18:06 +0100 Subject: [PATCH] Pass HsCircPool to hsclient connect function, not CircMgr We separated this out in the circmgr API. This is what the HS client needs. It doesn't want to participate in the general circuit pool. --- crates/arti-client/src/client.rs | 7 +++++-- crates/tor-hsclient/src/lib.rs | 8 ++++---- crates/tor-hsclient/src/state.rs | 3 ++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/crates/arti-client/src/client.rs b/crates/arti-client/src/client.rs index 7ab3ee568..4a3737c58 100644 --- a/crates/arti-client/src/client.rs +++ b/crates/arti-client/src/client.rs @@ -18,7 +18,10 @@ use tor_dirmgr::{DirMgrStore, Timeliness}; use tor_error::{internal, Bug, ErrorReport}; use tor_guardmgr::GuardMgr; #[cfg(feature = "onion-client")] -use tor_hsclient::{HsClientConnector, HsClientSecretKeys}; +use { + tor_circmgr::hspool::HsCircPool, + tor_hsclient::{HsClientConnector, HsClientSecretKeys} +}; use tor_netdir::{params::NetParameters, NetDirProvider}; use tor_persist::{FsStateMgr, StateMgr}; use tor_proto::circuit::ClientCirc; @@ -530,7 +533,7 @@ impl TorClient { #[cfg(feature = "onion-client")] let hsclient = HsClientConnector::new( runtime.clone(), - circmgr.clone(), + HsCircPool::new(&circmgr), dirmgr.clone().upcast_arc(), )?; diff --git a/crates/tor-hsclient/src/lib.rs b/crates/tor-hsclient/src/lib.rs index 82b11bda6..4fbf37723 100644 --- a/crates/tor-hsclient/src/lib.rs +++ b/crates/tor-hsclient/src/lib.rs @@ -49,8 +49,8 @@ use std::sync::{Arc, Mutex}; use educe::Educe; +use tor_circmgr::hspool::HsCircPool; use tor_circmgr::isolation::StreamIsolation; -use tor_circmgr::CircMgr; use tor_hscrypto::pk::HsId; use tor_netdir::NetDirProvider; use tor_proto::circuit::ClientCirc; @@ -79,7 +79,7 @@ pub struct HsClientConnector>, + circpool: Arc>, /// A [`NetDirProvider`] that we use to pick rendezvous points. netdir_provider: Arc, /// Information we are remembering about different onion services. @@ -92,14 +92,14 @@ impl HsClientConnector { /// Create a new `HsClientConnector` pub fn new( runtime: R, - circmgr: Arc>, + circpool: Arc>, netdir_provider: Arc, // TODO HS: there should be a config here, we will probably need it at some point // TODO HS: will needs a periodic task handle for us to expire old HS data/circuits ) -> Result { Ok(HsClientConnector { runtime, - circmgr, + circpool, netdir_provider, services: Arc::new(Mutex::new(Services::default())), mock_for_state: (), diff --git a/crates/tor-hsclient/src/state.rs b/crates/tor-hsclient/src/state.rs index 26d82dfc4..fbeff43e3 100644 --- a/crates/tor-hsclient/src/state.rs +++ b/crates/tor-hsclient/src/state.rs @@ -596,6 +596,7 @@ pub(crate) mod test { guardmgr, ) .unwrap(); + let circpool = HsCircPool::new(&circmgr); let netdir_provider = tor_netdir::testprovider::TestNetDirProvider::new(); let netdir_provider = Arc::new(netdir_provider); let (give_send, give) = postage::watch::channel_with(Ready(Ok(()))); @@ -603,7 +604,7 @@ pub(crate) mod test { #[allow(clippy::let_and_return)] // we'll probably add more in this function let hscc = HsClientConnector { runtime, - circmgr, + circpool, netdir_provider, services: Default::default(), mock_for_state,