From ca90f4dee8cc6515e19dfd126a3a3b2548a48ba0 Mon Sep 17 00:00:00 2001 From: zephyr Date: Mon, 18 Apr 2022 06:39:00 +0900 Subject: [PATCH] bidirectional handshake --- src/relay/tcp/mod.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/relay/tcp/mod.rs b/src/relay/tcp/mod.rs index 54cf765..4a7efe1 100644 --- a/src/relay/tcp/mod.rs +++ b/src/relay/tcp/mod.rs @@ -16,7 +16,7 @@ cfg_if! { } use std::io::Result; - +use futures::try_join; use log::debug; use tokio::net::TcpSocket; @@ -74,12 +74,10 @@ pub async fn connect_and_relay( #[cfg(feature = "transport")] { use kaminari::{AsyncAccept, AsyncConnect}; - use kaminari::mix::{MixClientStream, MixServerStream}; - type Inbound = MixServerStream; - type Outbound = MixClientStream; + if let Some((ac, cc)) = transport { - let mut inbound: Inbound = ac.accept(inbound).await?; - let mut outbound: Outbound = cc.connect(outbound).await?; + let (mut inbound, mut outbound) = + try_join!(ac.accept(inbound), cc.connect(outbound))?; tokio::io::copy_bidirectional(&mut inbound, &mut outbound) .await .map(|_| ())