From dcd854e697f7e0df86b37558708a60ac594e8a2b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Jul 2021 11:11:09 +0000 Subject: [PATCH 1/2] Bump torut from 0.1.9 to 0.1.10 Bumps [torut](https://github.com/teawithsand/torut) from 0.1.9 to 0.1.10. - [Release notes](https://github.com/teawithsand/torut/releases) - [Commits](https://github.com/teawithsand/torut/compare/v0.1.9...v0.1.10) --- updated-dependencies: - dependency-name: torut dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dad248ec..9017a96c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4294,9 +4294,9 @@ dependencies = [ [[package]] name = "torut" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05253df8056cc5830af67e5e86d6bb88bef83221238e698783f2560048584757" +checksum = "5b2cdfcb8b9dccc90fd618101a6f0a5a1f9e23e36956da9a2fe0abee901b04cc" dependencies = [ "base32", "base64 0.10.1", From c2daf7a11eed4b0f06d333479512056eb27671cc Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Tue, 6 Jul 2021 14:46:00 +1000 Subject: [PATCH 2/2] Make use of torut's errors implementing `std::error::Error` Anyhow all the things! --- swap/src/tor.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/swap/src/tor.rs b/swap/src/tor.rs index 4a6b3e3e..bbbcb16b 100644 --- a/swap/src/tor.rs +++ b/swap/src/tor.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, bail, Context, Result}; +use anyhow::{bail, Context, Result}; use std::future::Future; use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4}; use tokio::net::TcpStream; @@ -50,7 +50,7 @@ impl Client { pub async fn assert_tor_running(&self) -> Result<()> { // Make sure you are running tor and this is your socks port let proxy = reqwest::Proxy::all(format!("socks5h://{}", self.socks5_address).as_str()) - .map_err(|_| anyhow!("tor proxy should be there"))?; + .context("Failed to construct Tor proxy URL")?; let client = reqwest::Client::builder().proxy(proxy).build()?; let res = client.get("https://check.torproject.org").send().await?; @@ -77,21 +77,21 @@ impl Client { let mut uc = self .init_unauthenticated_connection() .await - .map_err(|_| anyhow!("Could not connect to Tor. Tor might not be running or the control port is incorrect."))?; + .context("Failed to connect to Tor")?; let tor_info = uc .load_protocol_info() .await - .map_err(|_| anyhow!("Failed to load protocol info from Tor."))?; + .context("Failed to load protocol info from Tor")?; let tor_auth_data = tor_info .make_auth_data()? - .context("Failed to make Tor auth data.")?; + .context("Failed to make Tor auth data")?; // Get an authenticated connection to the Tor via the Tor Controller protocol. uc.authenticate(&tor_auth_data) .await - .map_err(|_| anyhow!("Failed to authenticate with Tor"))?; + .context("Failed to authenticate with Tor")?; Ok(AuthenticatedClient { inner: uc.into_authenticated().await, @@ -123,6 +123,6 @@ impl AuthenticatedClient { self.inner .add_onion_v3(tor_key, false, false, false, None, &mut listeners) .await - .map_err(|e| anyhow!("Could not add onion service.: {:#?}", e)) + .context("Failed to add onion service") } }