Skip to content

Commit

Permalink
fix: put libtor behind optional feature flag (#3717)
Browse files Browse the repository at this point in the history
Description
---

Make libtor fully optional behind `libtor` feature flag since we are hitting a compilation issue on macos. 

MagicalBitcoin/libtor-sys#33
  • Loading branch information
Byron Hambly committed Jan 19, 2022
1 parent 548de8f commit e850cf0
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions applications/tari_base_node/Cargo.toml
Expand Up @@ -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"]


4 changes: 2 additions & 2 deletions applications/tari_base_node/src/main.rs
Expand Up @@ -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,
Expand Down Expand Up @@ -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)?;
Expand Down
1 change: 1 addition & 0 deletions applications/tari_console_wallet/Cargo.toml
Expand Up @@ -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"]

4 changes: 2 additions & 2 deletions applications/tari_console_wallet/src/main.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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 { .. })
{
Expand Down
2 changes: 1 addition & 1 deletion common/Cargo.toml
Expand Up @@ -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"

Expand Down
2 changes: 2 additions & 0 deletions common/config/presets/base_node.toml
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions common/config/presets/console_wallet.toml
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion common/src/lib.rs
Expand Up @@ -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;
Expand Down

0 comments on commit e850cf0

Please sign in to comment.