Skip to content

Instantly share code, notes, and snippets.

@carlosm27
Created April 18, 2023 23:58
Show Gist options
  • Save carlosm27/ce1a0f1ebdb2cec38d6b7621d68063f9 to your computer and use it in GitHub Desktop.
Save carlosm27/ce1a0f1ebdb2cec38d6b7621d68063f9 to your computer and use it in GitHub Desktop.
Tunnel function
async fn tunnel(mut upgraded: Upgraded, addr: String) -> std::io::Result<()> {
let mut server = TcpStream::connect(addr).await?;
let (from_client, from_server) =
tokio::io::copy_bidirectional(&mut upgraded, &mut server).await?;
tracing::debug!(
"client wrote {} bytes and received {} bytes",
from_client,
from_server
);
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment