aboutsummaryrefslogtreecommitdiffstats
path: root/src/transport/tor.rs
diff options
context:
space:
mode:
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"),