forked from comit-network/xmr-btc-swap
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a5c9bd
commit bb1fda1
Showing
11 changed files
with
2,607 additions
and
292 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,26 @@ | ||
use std::path::PathBuf; | ||
use std::sync::Arc; | ||
|
||
use arti::socks::run_socks_proxy; | ||
use arti_client::{config::TorClientConfigBuilder, TorClient, TorClientBuilder}; | ||
use arti_client::{config::TorClientConfigBuilder, Error, TorClient}; | ||
use tor_rtcompat::tokio::TokioRustlsRuntime; | ||
|
||
pub async fn init_tor_client(tor_socks5_port: u16, data_dir: PathBuf) -> Result<Arc<TorClient>> { | ||
pub async fn init_tor_client( | ||
data_dir: &PathBuf, | ||
) -> Result<Arc<TorClient<TokioRustlsRuntime>>, Error> { | ||
let data_dir = data_dir.join("tor"); | ||
let state_dir = data_dir.join("state"); | ||
let cache_dir = data_dir.join("cache"); | ||
|
||
// The client configuration describes how to connect to the Tor network, | ||
// and what directories to use for storing persistent state. | ||
let config = TorClientConfigBuilder::from_directories(state_dir, cache_dir).build()?; | ||
let config = TorClientConfigBuilder::from_directories(state_dir, cache_dir) | ||
.build() | ||
.unwrap(); | ||
|
||
// Start the Arti client, and let it bootstrap a connection to the Tor network. | ||
// (This takes a while to gather the necessary directory information. | ||
// It uses cached information when possible.) | ||
let tor_client = TorClient::create_bootstrapped(config).await?; | ||
|
||
run_socks_proxy(tor_client, tor_socks5_port).await?; | ||
Ok(Arc::new(tor_client)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.