mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
Simplify construction of Socks5Stream
This commit is contained in:
parent
ea0fd1eb53
commit
8bd6c9dcfc
@ -7,7 +7,7 @@ use libp2p::core::Transport;
|
|||||||
use libp2p::tcp::tokio::{Tcp, TcpStream};
|
use libp2p::tcp::tokio::{Tcp, TcpStream};
|
||||||
use libp2p::tcp::{GenTcpConfig, TcpListenStream, TokioTcpConfig};
|
use libp2p::tcp::{GenTcpConfig, TcpListenStream, TokioTcpConfig};
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};
|
use std::net::Ipv4Addr;
|
||||||
use tokio_socks::tcp::Socks5Stream;
|
use tokio_socks::tcp::Socks5Stream;
|
||||||
|
|
||||||
/// Represents the configuration for a Tor transport for libp2p.
|
/// Represents the configuration for a Tor transport for libp2p.
|
||||||
@ -45,10 +45,12 @@ impl Transport for TorTcpConfig {
|
|||||||
Ok(tor_address_string) => Ok(async move {
|
Ok(tor_address_string) => Ok(async move {
|
||||||
tracing::trace!("Connecting through Tor proxy to address: {}", addr);
|
tracing::trace!("Connecting through Tor proxy to address: {}", addr);
|
||||||
|
|
||||||
let sock = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::LOCALHOST, self.socks_port));
|
let stream = Socks5Stream::connect(
|
||||||
let stream = Socks5Stream::connect(sock, tor_address_string)
|
(Ipv4Addr::LOCALHOST, self.socks_port),
|
||||||
.await
|
tor_address_string,
|
||||||
.map_err(|e| io::Error::new(io::ErrorKind::ConnectionRefused, e))?;
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| io::Error::new(io::ErrorKind::ConnectionRefused, e))?;
|
||||||
|
|
||||||
tracing::trace!("Connection through Tor established");
|
tracing::trace!("Connection through Tor established");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user