From 6d2737099ba2ba5ad885322f19bb790e20bb45ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Fri, 12 May 2023 13:37:21 +0100 Subject: [PATCH] additional target os locking --- common/socks5-client-core/src/config/mod.rs | 4 +-- .../src/config/old_config_v1_1_13.rs | 4 +-- common/socks5-client-core/src/lib.rs | 26 ++++++++++++++++++- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/common/socks5-client-core/src/config/mod.rs b/common/socks5-client-core/src/config/mod.rs index fbe5f06c8d..a8edc89549 100644 --- a/common/socks5-client-core/src/config/mod.rs +++ b/common/socks5-client-core/src/config/mod.rs @@ -36,9 +36,9 @@ impl NymConfig for Config { } fn default_root_directory() -> PathBuf { - #[cfg(not(target_os = "android"))] + #[cfg(not(any(target_os = "android", target_os = "ios")))] let base_dir = dirs::home_dir().expect("Failed to evaluate $HOME value"); - #[cfg(target_os = "android")] + #[cfg(any(target_os = "android", target_os = "ios"))] let base_dir = PathBuf::from("/tmp"); base_dir.join(".nym").join("socks5-clients") diff --git a/common/socks5-client-core/src/config/old_config_v1_1_13.rs b/common/socks5-client-core/src/config/old_config_v1_1_13.rs index 241acf96a6..754b363d81 100644 --- a/common/socks5-client-core/src/config/old_config_v1_1_13.rs +++ b/common/socks5-client-core/src/config/old_config_v1_1_13.rs @@ -23,9 +23,9 @@ impl NymConfig for OldConfigV1_1_13 { } fn default_root_directory() -> PathBuf { - #[cfg(not(target_os = "android"))] + #[cfg(not(any(target_os = "android", target_os = "ios")))] let base_dir = dirs::home_dir().expect("Failed to evaluate $HOME value"); - #[cfg(target_os = "android")] + #[cfg(any(target_os = "android", target_os = "ios"))] let base_dir = PathBuf::from("/tmp"); base_dir.join(".nym").join("socks5-clients") diff --git a/common/socks5-client-core/src/lib.rs b/common/socks5-client-core/src/lib.rs index 925aa76bf8..550550b2fb 100644 --- a/common/socks5-client-core/src/lib.rs +++ b/common/socks5-client-core/src/lib.rs @@ -16,6 +16,7 @@ use nym_client_core::client::base_client::{ }; use nym_client_core::client::key_manager::KeyManager; use nym_client_core::config::persistence::key_pathfinder::ClientKeyPathfinder; +use nym_client_core::config::DebugConfig; use nym_credential_storage::storage::Storage; use nym_sphinx::addressing::clients::Recipient; use nym_task::{TaskClient, TaskManager}; @@ -23,9 +24,10 @@ use nym_validator_client::nyxd::QueryNyxdClient; use nym_validator_client::Client; use std::error::Error; +#[cfg(any(target_os = "android", target_os = "ios"))] use nym_client_core::client::base_client::helpers::setup_empty_reply_surb_backend; +#[cfg(not(any(target_os = "android", target_os = "ios")))] use nym_client_core::client::base_client::non_wasm_helpers; -use nym_client_core::config::DebugConfig; pub mod config; pub mod error; @@ -246,6 +248,28 @@ impl NymClient { } pub async fn start(self) -> Result { + #[cfg(not(any(target_os = "android", target_os = "ios")))] + let base_builder = BaseClientBuilder::new_from_base_config( + self.config.get_base(), + self.key_manager, + Some( + Self::create_bandwidth_controller( + &self.config, + nym_credential_storage::initialise_persistent_storage( + self.config.get_base().get_database_path(), + ) + .await, + ) + .await, + ), + non_wasm_helpers::setup_fs_reply_surb_backend( + Some(self.config.get_base().get_reply_surb_database_path()), + self.config.get_debug_settings(), + ) + .await?, + ); + + #[cfg(any(target_os = "android", target_os = "ios"))] let base_builder = BaseClientBuilder::<_, Client, _>::new_from_base_config( self.config.get_base(), self.key_manager,