From a1698f36a6953074d93d92ece0278cd441f18a49 Mon Sep 17 00:00:00 2001 From: Karolin Varner Date: Sat, 2 Aug 2025 19:13:21 +0200 Subject: [PATCH] fix(rp): Start the proper rosenpass server on a dedicated thread We should not block the tokio executor indefinetly. --- cipher-traits/src/primitives/keyed_hash.rs | 2 +- rosenpass/src/app_server.rs | 8 ++++---- rosenpass/src/cli.rs | 2 +- rp/src/exchange.rs | 5 +++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cipher-traits/src/primitives/keyed_hash.rs b/cipher-traits/src/primitives/keyed_hash.rs index 93ecaf1..426cc78 100644 --- a/cipher-traits/src/primitives/keyed_hash.rs +++ b/cipher-traits/src/primitives/keyed_hash.rs @@ -40,7 +40,7 @@ pub struct InferKeyedHash where Static: KeyedHash, { - pub _phantom_keyed_hasher: PhantomData<*const Static>, + pub _phantom_keyed_hasher: PhantomData, } impl InferKeyedHash diff --git a/rosenpass/src/app_server.rs b/rosenpass/src/app_server.rs index cd406f9..59f3192 100644 --- a/rosenpass/src/app_server.rs +++ b/rosenpass/src/app_server.rs @@ -129,7 +129,7 @@ pub struct BrokerStore { /// The collection of WireGuard brokers. See [Self]. pub store: HashMap< Public, - Box>, + Box + Send>, >, } @@ -146,12 +146,12 @@ pub struct BrokerPeer { /// /// This is woefully overengineered and there is very little reason why the broker /// configuration should not live in the particular WireGuard broker. - peer_cfg: Box, + peer_cfg: Box, } impl BrokerPeer { /// Create a broker peer - pub fn new(ptr: BrokerStorePtr, peer_cfg: Box) -> Self { + pub fn new(ptr: BrokerStorePtr, peer_cfg: Box) -> Self { Self { ptr, peer_cfg } } @@ -977,7 +977,7 @@ impl AppServer { /// Register a new WireGuard PSK broker pub fn register_broker( &mut self, - broker: Box>, + broker: Box + Send>, ) -> Result { let ptr = Public::from_slice((self.brokers.store.len() as u64).as_bytes()); if self.brokers.store.insert(ptr, broker).is_some() { diff --git a/rosenpass/src/cli.rs b/rosenpass/src/cli.rs index 186f617..bd8b837 100644 --- a/rosenpass/src/cli.rs +++ b/rosenpass/src/cli.rs @@ -515,7 +515,7 @@ impl CliArgs { fn create_broker( broker_interface: Option, ) -> Result< - Box>, + Box + Send>, anyhow::Error, > { if let Some(interface) = broker_interface { diff --git a/rp/src/exchange.rs b/rp/src/exchange.rs index 392b0ab..71e7a4c 100644 --- a/rp/src/exchange.rs +++ b/rp/src/exchange.rs @@ -22,8 +22,9 @@ use rosenpass_util::functional::{ApplyExt, MutatingExt}; use rosenpass_util::result::OkExt; use rosenpass_util::tokio::janitor::{spawn_cleanup_job, try_spawn_daemon}; use rosenpass_wireguard_broker::brokers::native_unix::{ - NativeUnixBroker, NativeUnixBrokerConfigBaseBuilder, NativeUnixBrokerConfigBaseBuilderError, + NativeUnixBroker, NativeUnixBrokerConfigBaseBuilder, }; +use tokio::task::spawn_blocking; use crate::key::WG_B64_LEN; @@ -528,5 +529,5 @@ pub async fn exchange(options: ExchangeOptions) -> Result<()> { } log::info!("Starting to perform rosenpass key exchanges!"); - srv.event_loop() + spawn_blocking(move || srv.event_loop()).await? }