Move TCP connection to inside the task

This commit is contained in:
Yash Karandikar 2022-06-24 20:40:17 +05:30
parent d9037a590f
commit f66a77dc62
2 changed files with 2 additions and 2 deletions

View File

@ -25,6 +25,6 @@ If no path is provided, `atp` will fall back to looking for `config.toml` in the
TODO:
- [ ] more descriptive error messages
- [ ] use spawing + channels instead of `select!`
- [ ] use spawning + channels instead of `select!`
- [ ] on-the-fly config reload?
- [ ] UDP proxying?

View File

@ -20,9 +20,9 @@ async fn main() -> anyhow::Result<()> {
let listener = TcpListener::bind(SocketAddr::new("0.0.0.0".parse()?, port)).await?;
loop {
let (stream, _) = listener.accept().await?;
let to_stream = TcpStream::connect(saddr).await?;
tokio::spawn(async move {
let to_stream = TcpStream::connect(saddr).await?;
proxy(stream, to_stream).await?;
Ok::<(), anyhow::Error>(())
});