mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-03 03:56:22 -04:00
Optimize torut features.
OnionV2 addresses are being deprecated and will be fully phased out on 15.10.2021: https://blog.torproject.org/v2-deprecation-timeline
This commit is contained in:
parent
632293cf91
commit
3a5395d7a5
4 changed files with 12 additions and 69 deletions
|
@ -54,7 +54,7 @@ tokio-socks = "0.5"
|
|||
tokio-tungstenite = { version = "0.14", features = [ "rustls-tls" ] }
|
||||
tokio-util = { version = "0.6", features = ["io"] }
|
||||
toml = "0.5"
|
||||
torut = "0.1"
|
||||
torut = { version = "0.1", default-features = false, features = ["v3", "control"] }
|
||||
tracing = { version = "0.1", features = ["attributes"] }
|
||||
tracing-appender = "0.1"
|
||||
tracing-futures = { version = "0.2", features = ["std-future", "futures-03"] }
|
||||
|
|
|
@ -13,7 +13,7 @@ use std::pin::Pin;
|
|||
use tokio_socks::tcp::Socks5Stream;
|
||||
use tokio_socks::IntoTargetAddr;
|
||||
|
||||
/// Represents the configuration for a TCP/IP transport capability for libp2p.
|
||||
/// Represents the configuration for a Tor transport for libp2p.
|
||||
#[derive(Clone)]
|
||||
pub struct TorTcpConfig {
|
||||
inner: GenTcpConfig<Tcp>,
|
||||
|
@ -79,25 +79,12 @@ impl Transport for TorTcpConfig {
|
|||
fn to_address_string(multi: Multiaddr) -> Option<String> {
|
||||
let components = multi.iter();
|
||||
for protocol in components {
|
||||
match protocol {
|
||||
Protocol::Onion(addr, port) => {
|
||||
tracing::warn!("Onion service v2 is being deprecated, consider upgrading to v3");
|
||||
return Some(format!(
|
||||
"{}.onion:{}",
|
||||
BASE32.encode(addr.as_ref()).to_lowercase(),
|
||||
port
|
||||
));
|
||||
}
|
||||
Protocol::Onion3(addr) => {
|
||||
return Some(format!(
|
||||
"{}.onion:{}",
|
||||
BASE32.encode(addr.hash()).to_lowercase(),
|
||||
addr.port()
|
||||
));
|
||||
}
|
||||
_ => {
|
||||
// ignore
|
||||
}
|
||||
if let Protocol::Onion3(addr) = protocol {
|
||||
return Some(format!(
|
||||
"{}.onion:{}",
|
||||
BASE32.encode(addr.hash()).to_lowercase(),
|
||||
addr.port()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue