From 43b0b2b426b244a4176fd545d8ac1a611455660c Mon Sep 17 00:00:00 2001 From: cloudhead Date: Sun, 5 May 2024 00:34:27 +0200 Subject: [PATCH] node: Always go through proxy with Tor Force the proxy for regular connections, when Tor is configured. --- radicle-node/src/wire/protocol.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/radicle-node/src/wire/protocol.rs b/radicle-node/src/wire/protocol.rs index be54c789..67dc0bca 100644 --- a/radicle-node/src/wire/protocol.rs +++ b/radicle-node/src/wire/protocol.rs @@ -1085,6 +1085,8 @@ pub fn dial>( NetAddr::new(host, remote_addr.port) } }; + // Whether to tunnel regular connections through the proxy. + let force_proxy = matches!(config.tor, Some(TorConfig::Proxy { .. })); // Nb. This timeout is currently not used by the underlying library due to the // `socket2` library not supporting non-blocking connect with timeout. let connection = net::TcpStream::connect_nonblocking(inet_addr, DEFAULT_DIAL_TIMEOUT)?; @@ -1096,6 +1098,7 @@ pub fn dial>( remote_addr, Some(remote_id), connection, + force_proxy, signer, )) } @@ -1106,7 +1109,7 @@ pub fn accept>( connection: net::TcpStream, signer: G, ) -> WireSession { - session::(remote_addr, None, connection, signer) + session::(remote_addr, None, connection, false, signer) } /// Create a new [`WireSession`]. @@ -1114,9 +1117,10 @@ fn session>( remote_addr: NetAddr, remote_id: Option, connection: net::TcpStream, + force_proxy: bool, signer: G, ) -> WireSession { - let socks5 = socks5::Socks5::with(remote_addr, false); + let socks5 = socks5::Socks5::with(remote_addr, force_proxy); let proxy = Socks5Session::with(connection, socks5); let pair = G::generate_keypair(); let keyset = Keyset {