Move TCP connection to inside the task
This commit is contained in:
parent
d9037a590f
commit
f66a77dc62
|
@ -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?
|
||||
|
|
|
@ -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>(())
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue