From e850cf076b1803afe1fddcbcbe21dfaf92e6b103 Mon Sep 17 00:00:00 2001 From: Byron Hambly Date: Wed, 19 Jan 2022 20:05:12 +0200 Subject: [PATCH] fix: put libtor behind optional feature flag (#3717) Description --- Make libtor fully optional behind `libtor` feature flag since we are hitting a compilation issue on macos. magicalbitcoin/libtor-sys#33 --- applications/tari_base_node/Cargo.toml | 1 + applications/tari_base_node/src/main.rs | 4 ++-- applications/tari_console_wallet/Cargo.toml | 1 + applications/tari_console_wallet/src/main.rs | 4 ++-- common/Cargo.toml | 2 +- common/config/presets/base_node.toml | 2 ++ common/config/presets/console_wallet.toml | 2 ++ common/src/lib.rs | 2 +- 8 files changed, 12 insertions(+), 6 deletions(-) diff --git a/applications/tari_base_node/Cargo.toml b/applications/tari_base_node/Cargo.toml index 36fed83695..75ffda022e 100644 --- a/applications/tari_base_node/Cargo.toml +++ b/applications/tari_base_node/Cargo.toml @@ -57,5 +57,6 @@ default = ["metrics"] avx2 = ["tari_core/avx2", "tari_crypto/avx2", "tari_p2p/avx2", "tari_comms/avx2", "tari_comms_dht/avx2"] metrics = ["warp", "reqwest", "tari_metrics", "tari_comms/metrics"] safe = [] +libtor = ["tari_common/libtor"] diff --git a/applications/tari_base_node/src/main.rs b/applications/tari_base_node/src/main.rs index af96a52516..5e08d7c84b 100644 --- a/applications/tari_base_node/src/main.rs +++ b/applications/tari_base_node/src/main.rs @@ -119,7 +119,7 @@ use tari_app_utilities::{ utilities::setup_runtime, }; use tari_common::{configuration::bootstrap::ApplicationType, exit_codes::ExitCodes, ConfigBootstrap, GlobalConfig}; -#[cfg(unix)] +#[cfg(all(unix, feature = "libtor"))] use tari_common::{tor::Tor, CommsTransport}; use tari_comms::{ peer_manager::PeerFeatures, @@ -192,7 +192,7 @@ fn main_inner() -> Result<(), ExitCodes> { // Run our own Tor instance, if configured // This is currently only possible on linux/macos - #[cfg(unix)] + #[cfg(all(unix, feature = "libtor"))] if config.base_node_use_libtor && matches!(config.comms_transport, CommsTransport::TorHiddenService { .. }) { let tor = Tor::initialize()?; config.comms_transport = tor.update_comms_transport(config.comms_transport)?; diff --git a/applications/tari_console_wallet/Cargo.toml b/applications/tari_console_wallet/Cargo.toml index 5d75855238..edb0052fce 100644 --- a/applications/tari_console_wallet/Cargo.toml +++ b/applications/tari_console_wallet/Cargo.toml @@ -57,4 +57,5 @@ features = ["crossterm"] [features] avx2 = ["tari_core/avx2", "tari_crypto/avx2", "tari_wallet/avx2", "tari_comms/avx2", "tari_comms_dht/avx2", "tari_p2p/avx2", "tari_key_manager/avx2"] +libtor = ["tari_common/libtor"] diff --git a/applications/tari_console_wallet/src/main.rs b/applications/tari_console_wallet/src/main.rs index 62a967c73a..ec2b8b37ec 100644 --- a/applications/tari_console_wallet/src/main.rs +++ b/applications/tari_console_wallet/src/main.rs @@ -47,7 +47,7 @@ use opentelemetry::{self, global, KeyValue}; use recovery::prompt_private_key_from_seed_words; use tari_app_utilities::{consts, initialization::init_configuration}; use tari_common::{configuration::bootstrap::ApplicationType, exit_codes::ExitCodes, ConfigBootstrap}; -#[cfg(unix)] +#[cfg(all(unix, feature = "libtor"))] use tari_common::{tor::Tor, CommsTransport}; use tari_key_manager::cipher_seed::CipherSeed; use tari_shutdown::Shutdown; @@ -137,7 +137,7 @@ fn main_inner() -> Result<(), ExitCodes> { // Run our own Tor instance, if configured // This is currently only possible on linux/macos - #[cfg(unix)] + #[cfg(all(unix, feature = "libtor"))] if global_config.console_wallet_use_libtor && matches!(global_config.comms_transport, CommsTransport::TorHiddenService { .. }) { diff --git a/common/Cargo.toml b/common/Cargo.toml index 75a331b467..cb32c47b86 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -38,7 +38,7 @@ tempfile = "3.1.0" [target.'cfg(unix)'.dependencies] tari_shutdown = { version = "^0.24", path = "../infrastructure/shutdown"} -libtor = "46.9" +libtor = { version = "46.9.0", optional = true } rand = "0.8" tor-hash-passwd = "1.0.1" diff --git a/common/config/presets/base_node.toml b/common/config/presets/base_node.toml index 711f6f0602..48489db933 100644 --- a/common/config/presets/base_node.toml +++ b/common/config/presets/base_node.toml @@ -111,6 +111,7 @@ base_node_identity_file = "config/base_node_id.json" transport = "tor" # Spin up and use a built-in Tor instance. This only works on macos/linux and you must comment out tor_control_address below. +# This requires that the base node was built with the optional "libtor" feature flag. #use_libtor = true # Address of the tor control server @@ -288,6 +289,7 @@ console_wallet_identity_file = "config/console_wallet_id.json" transport = "tor" # Spin up and use a built-in Tor instance. This only works on macos/linux and you must comment out tor_control_address below. +# This requires that the base node was built with the optional "libtor" feature flag. #use_libtor = true # Address of the tor control server diff --git a/common/config/presets/console_wallet.toml b/common/config/presets/console_wallet.toml index 89c7d5c3d1..fb5e63065e 100644 --- a/common/config/presets/console_wallet.toml +++ b/common/config/presets/console_wallet.toml @@ -122,6 +122,7 @@ base_node_service_request_max_age = 180 transport = "tor" # Spin up and use a built-in Tor instance. This only works on macos/linux and you must comment out tor_control_address below. +# This requires that the wallet was built with the optional "libtor" feature flag. #use_libtor = true # Address of the tor control server @@ -176,6 +177,7 @@ tor_control_address = "/ip4/127.0.0.1/tcp/9051" transport = "tor" # Spin up and use a built-in Tor instance. This only works on macos/linux and you must comment out tor_control_address below. +# This requires that the wallet was built with the optional "libtor" feature flag. #use_libtor = true # Address of the tor control server diff --git a/common/src/lib.rs b/common/src/lib.rs index d638ee375b..a5393db9d8 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -81,7 +81,7 @@ #[cfg(any(feature = "build", feature = "static-application-info"))] pub mod build; pub mod exit_codes; -#[cfg(unix)] +#[cfg(all(unix, feature = "libtor"))] pub mod tor; #[macro_use] mod logging;