aboutsummaryrefslogtreecommitdiffstats
path: root/src/transport/tor.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-30 15:36:47 +0100
committertv <tv@krebsco.de>2026-10-30 15:46:12 +0100
commitfacf96e278415b98ff9d7032c7c353f8dc227f6b (patch)
tree45ce4c83a44208a25e226cf07aabd4be15016b96 /src/transport/tor.rs
parent785d4f136da4ef556d29fc4f56258d7e6350b96b (diff)
refactor transports to start themselves
Diffstat (limited to 'src/transport/tor.rs')
-rw-r--r--src/transport/tor.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/transport/tor.rs b/src/transport/tor.rs
index 2cf3249..8eb1d02 100644
--- a/src/transport/tor.rs
+++ b/src/transport/tor.rs
@@ -198,6 +198,28 @@ impl TorTransport {
/// while: it fetches what it needs to know of the Tor network). Until it is done,
/// dials wait for it (arti bootstraps on demand), and the onion service is published
/// once it is: the node starts without waiting for Tor.
+ /// The transport as `settings` configure it (`transport::start`), proving `key`.
+ /// None if `stop` came first (bootstrapping arti can take a while).
+ pub(crate) async fn from_settings(
+ settings: &crate::config::Settings,
+ key: &Arc<NodeKey>,
+ mut stop: watch::Receiver<bool>,
+ ) -> Result<Option<Self>> {
+ let state_dir = settings
+ .tor_state_dir
+ .clone()
+ .context("tor needs tor-state-dir")?;
+ let config = TorConfig {
+ key: Arc::clone(key),
+ state_dir,
+ port: settings.tor_port,
+ };
+ tokio::select! {
+ transport = Self::start(config) => transport.map(Some),
+ _ = stop.wait_for(|stop| *stop) => Ok(None),
+ }
+ }
+
pub(crate) async fn start(config: TorConfig) -> Result<Self> {
let tor_config = TorClientConfigBuilder::from_directories(
config.state_dir.join("state"),