From fa017bb6a065ad77ca4edb71f31ffb501b9a232c Mon Sep 17 00:00:00 2001 From: vkill Date: Fri, 2 Dec 2022 21:55:28 +0800 Subject: [PATCH] Fix "inbound-http" feature (#323) --- leaf/src/proxy/http/inbound/{tcp.rs => stream.rs} | 7 ++----- leaf/src/proxy/ws/inbound/stream.rs | 4 ++-- leaf/src/proxy/ws/outbound/stream.rs | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) rename leaf/src/proxy/http/inbound/{tcp.rs => stream.rs} (94%) diff --git a/leaf/src/proxy/http/inbound/tcp.rs b/leaf/src/proxy/http/inbound/stream.rs similarity index 94% rename from leaf/src/proxy/http/inbound/tcp.rs rename to leaf/src/proxy/http/inbound/stream.rs index 41bec9c..c8e6bb9 100644 --- a/leaf/src/proxy/http/inbound/tcp.rs +++ b/leaf/src/proxy/http/inbound/stream.rs @@ -59,7 +59,7 @@ impl InboundStreamHandler for Handler { &'a self, mut sess: Session, stream: Box, - ) -> std::io::Result { + ) -> std::io::Result { let http = Http::new(); let proxy_service = ProxyService::new(); let conn = http @@ -99,9 +99,6 @@ impl InboundStreamHandler for Handler { sess.destination = destination; - Ok(InboundTransport::Stream( - Box::new(SimpleProxyStream(parts.io)), - sess, - )) + Ok(InboundTransport::Stream(Box::new(parts.io), sess)) } } diff --git a/leaf/src/proxy/ws/inbound/stream.rs b/leaf/src/proxy/ws/inbound/stream.rs index 87c62fc..91d0472 100644 --- a/leaf/src/proxy/ws/inbound/stream.rs +++ b/leaf/src/proxy/ws/inbound/stream.rs @@ -21,8 +21,8 @@ impl<'a> SimpleCallback<'a> { impl<'a> Callback for SimpleCallback<'a> { fn on_request(self, request: &Request, response: Response) -> Result { if request.uri().path() != self.path { - return Err(http::response::Response::builder() - .status(http::StatusCode::NOT_FOUND) + return Err(::http::response::Response::builder() + .status(::http::StatusCode::NOT_FOUND) .body(None) .unwrap()); } diff --git a/leaf/src/proxy/ws/outbound/stream.rs b/leaf/src/proxy/ws/outbound/stream.rs index de84b3d..6b3fde8 100644 --- a/leaf/src/proxy/ws/outbound/stream.rs +++ b/leaf/src/proxy/ws/outbound/stream.rs @@ -23,7 +23,7 @@ impl<'a> tungstenite::client::IntoClientRequest for Request<'a> { fn into_client_request( self, ) -> tungstenite::error::Result { - let mut builder = http::Request::builder() + let mut builder = ::http::Request::builder() .method("GET") .uri(self.uri) .header("User-Agent", &*crate::option::HTTP_USER_AGENT);