fix(rp): Start the proper rosenpass server on a dedicated thread

We should not block the tokio executor indefinetly.
This commit is contained in:
Karolin Varner
2025-08-02 19:13:21 +02:00
parent 2d6550da0f
commit a1698f36a6
4 changed files with 9 additions and 8 deletions

View File

@@ -40,7 +40,7 @@ pub struct InferKeyedHash<Static, const KEY_LEN: usize, const HASH_LEN: usize>
where where
Static: KeyedHash<KEY_LEN, HASH_LEN>, Static: KeyedHash<KEY_LEN, HASH_LEN>,
{ {
pub _phantom_keyed_hasher: PhantomData<*const Static>, pub _phantom_keyed_hasher: PhantomData<Static>,
} }
impl<Static, const KEY_LEN: usize, const HASH_LEN: usize> InferKeyedHash<Static, KEY_LEN, HASH_LEN> impl<Static, const KEY_LEN: usize, const HASH_LEN: usize> InferKeyedHash<Static, KEY_LEN, HASH_LEN>

View File

@@ -129,7 +129,7 @@ pub struct BrokerStore {
/// The collection of WireGuard brokers. See [Self]. /// The collection of WireGuard brokers. See [Self].
pub store: HashMap< pub store: HashMap<
Public<BROKER_ID_BYTES>, Public<BROKER_ID_BYTES>,
Box<dyn WireguardBrokerMio<Error = anyhow::Error, MioError = anyhow::Error>>, Box<dyn WireguardBrokerMio<Error = anyhow::Error, MioError = anyhow::Error> + Send>,
>, >,
} }
@@ -146,12 +146,12 @@ pub struct BrokerPeer {
/// ///
/// This is woefully overengineered and there is very little reason why the broker /// This is woefully overengineered and there is very little reason why the broker
/// configuration should not live in the particular WireGuard broker. /// configuration should not live in the particular WireGuard broker.
peer_cfg: Box<dyn WireguardBrokerCfg>, peer_cfg: Box<dyn WireguardBrokerCfg + Send>,
} }
impl BrokerPeer { impl BrokerPeer {
/// Create a broker peer /// Create a broker peer
pub fn new(ptr: BrokerStorePtr, peer_cfg: Box<dyn WireguardBrokerCfg>) -> Self { pub fn new(ptr: BrokerStorePtr, peer_cfg: Box<dyn WireguardBrokerCfg + Send>) -> Self {
Self { ptr, peer_cfg } Self { ptr, peer_cfg }
} }
@@ -977,7 +977,7 @@ impl AppServer {
/// Register a new WireGuard PSK broker /// Register a new WireGuard PSK broker
pub fn register_broker( pub fn register_broker(
&mut self, &mut self,
broker: Box<dyn WireguardBrokerMio<Error = anyhow::Error, MioError = anyhow::Error>>, broker: Box<dyn WireguardBrokerMio<Error = anyhow::Error, MioError = anyhow::Error> + Send>,
) -> Result<BrokerStorePtr> { ) -> Result<BrokerStorePtr> {
let ptr = Public::from_slice((self.brokers.store.len() as u64).as_bytes()); let ptr = Public::from_slice((self.brokers.store.len() as u64).as_bytes());
if self.brokers.store.insert(ptr, broker).is_some() { if self.brokers.store.insert(ptr, broker).is_some() {

View File

@@ -515,7 +515,7 @@ impl CliArgs {
fn create_broker( fn create_broker(
broker_interface: Option<BrokerInterface>, broker_interface: Option<BrokerInterface>,
) -> Result< ) -> Result<
Box<dyn WireguardBrokerMio<MioError = anyhow::Error, Error = anyhow::Error>>, Box<dyn WireguardBrokerMio<MioError = anyhow::Error, Error = anyhow::Error> + Send>,
anyhow::Error, anyhow::Error,
> { > {
if let Some(interface) = broker_interface { if let Some(interface) = broker_interface {

View File

@@ -22,8 +22,9 @@ use rosenpass_util::functional::{ApplyExt, MutatingExt};
use rosenpass_util::result::OkExt; use rosenpass_util::result::OkExt;
use rosenpass_util::tokio::janitor::{spawn_cleanup_job, try_spawn_daemon}; use rosenpass_util::tokio::janitor::{spawn_cleanup_job, try_spawn_daemon};
use rosenpass_wireguard_broker::brokers::native_unix::{ use rosenpass_wireguard_broker::brokers::native_unix::{
NativeUnixBroker, NativeUnixBrokerConfigBaseBuilder, NativeUnixBrokerConfigBaseBuilderError, NativeUnixBroker, NativeUnixBrokerConfigBaseBuilder,
}; };
use tokio::task::spawn_blocking;
use crate::key::WG_B64_LEN; 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!"); log::info!("Starting to perform rosenpass key exchanges!");
srv.event_loop() spawn_blocking(move || srv.event_loop()).await?
} }