From c1d93942cc611430b38e48e71d604e92cf62417f Mon Sep 17 00:00:00 2001 From: ssrlive <30760636+ssrlive@users.noreply.github.com> Date: Mon, 8 Apr 2024 14:24:41 +0800 Subject: [PATCH] async-recursion removed --- Cargo.toml | 2 +- src/http.rs | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 45c4a1b..b2c5b6e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,12 +8,12 @@ homepage = "https://github.com/blechschmidt/tun2proxy" authors = ["B. Blechschmidt", "ssrlive"] description = "Tunnel interface to proxy" readme = "README.md" +rust-version = "1.77" [lib] crate-type = ["staticlib", "cdylib", "lib"] [dependencies] -async-recursion = "1.1" async-trait = "0.1" base64 = { version = "0.22" } chrono = "0.4" diff --git a/src/http.rs b/src/http.rs index 79c403a..00a14b4 100644 --- a/src/http.rs +++ b/src/http.rs @@ -152,7 +152,6 @@ impl HttpConnection { Ok(()) } - #[async_recursion::async_recursion] async fn state_change(&mut self) -> Result<()> { match self.state { HttpState::ExpectResponseHeaders => { @@ -200,7 +199,7 @@ impl HttpConnection { // The server may have sent a banner already (SMTP, SSH, etc.). // Therefore, server_inbuf must retain this data. self.server_inbuf.drain(0..header_size); - return self.state_change().await; + return Box::pin(self.state_change()).await; } if status_code != 407 { @@ -295,7 +294,7 @@ impl HttpConnection { self.state = HttpState::ExpectResponse; self.skip = content_length + len; - return self.state_change().await; + return Box::pin(self.state_change()).await; } HttpState::ExpectResponse => { if self.skip > 0 { @@ -312,7 +311,7 @@ impl HttpConnection { self.send_tunnel_request().await?; self.state = HttpState::ExpectResponseHeaders; - return self.state_change().await; + return Box::pin(self.state_change()).await; } } HttpState::Established => { @@ -323,7 +322,7 @@ impl HttpConnection { } HttpState::Reset => { self.state = HttpState::ExpectResponseHeaders; - return self.state_change().await; + return Box::pin(self.state_change()).await; } _ => {} }