From f7287bd9adcc52e0a42c579b1daf9aa6c76e31db Mon Sep 17 00:00:00 2001 From: ardocrat Date: Mon, 25 May 2026 16:32:13 +0300 Subject: [PATCH] tor: create runtime only once --- src/tor/tor.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tor/tor.rs b/src/tor/tor.rs index 4790614..b13b995 100644 --- a/src/tor/tor.rs +++ b/src/tor/tor.rs @@ -60,6 +60,7 @@ lazy_static! { /// Tor client to use as SOCKS proxy for requests and to launch Onion services. pub struct Tor { + runtime: TokioNativeTlsRuntime, /// Tor client and config. client_config: Arc, TorClientConfig)>>>, /// Flag to check if client is launching. @@ -97,6 +98,7 @@ impl Default for Tor { } } Self { + runtime: TokioNativeTlsRuntime::create().unwrap(), client_config: Arc::new(RwLock::new(None)), client_launching: Arc::new(AtomicBool::new(false)), run: Arc::new(RwLock::new(BTreeMap::new())), @@ -140,8 +142,7 @@ impl Tor { /// Build bootstrapped client from provided config. fn build_client_bootstrap(config: TorClientConfig) -> Option> { - let runtime = TokioNativeTlsRuntime::create().unwrap(); - let client_res = TorClient::with_runtime(runtime) + let client_res = TorClient::with_runtime(TOR_STATE.runtime.clone()) .config(config.clone()) .create_unbootstrapped(); if client_res.is_err() {