Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ impl ConnectionType {
}
}
}

fn is_proxy(&self) -> bool {
matches!(self, ConnectionType::Socks5Proxy(_))
}
}

#[derive(Debug, Clone)]
Expand Down
8 changes: 6 additions & 2 deletions src/network/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,18 @@ impl Peer {
}
}

pub async fn run(&mut self, connection: TcpStream) -> Result<(), PeerError> {
pub async fn run(
&mut self,
connection: TcpStream,
is_proxy_connection: bool,
) -> Result<(), PeerError> {
let start_time = Instant::now();
let (tx, mut rx) = mpsc::channel(32);
let (reader, mut writer) = connection.into_split();
let mut reader = BufReader::new(reader);
// If a peer signals for V2 we will use it, otherwise just use plaintext.
let (mut outbound_messages, mut peer_reader) =
if self.source.service_flags().has(ServiceFlags::P2P_V2) {
if self.source.service_flags().has(ServiceFlags::P2P_V2) && !is_proxy_connection {
let handshake_result = tokio::time::timeout(
V2_HANDSHAKE_TIMEOUT,
self.try_handshake(&mut writer, &mut reader),
Expand Down
3 changes: 2 additions & 1 deletion src/network/peer_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ impl PeerMap {
return Err(e);
}
};
let handle = tokio::spawn(async move { peer.run(connection).await });
let is_proxy = self.connector.is_proxy();
let handle = tokio::spawn(async move { peer.run(connection, is_proxy).await });
self.map.insert(
self.current_id,
ManagedPeer {
Expand Down