From 067998cead9d53ba1eac96ec0b9a745f549a56f8 Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Sun, 14 Apr 2024 06:23:36 -0400 Subject: [PATCH] Update to Hyper 1. Also updated all other depends. --- Cargo.toml | 22 +++++++++++----------- src/lib.rs | 24 +++++++++--------------- src/stream.rs | 2 +- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9f8601f..2c56c21 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,28 +15,28 @@ edition = "2018" [dependencies] tokio = { version = "1", features = ["io-std", "io-util"] } -hyper = { version = "0.14", features = ["client"] } +hyper = { version = "1", features = ["client"] } tower-service = "0.3" -http = "0.2" +http = "1" futures-util = { version = "0.3", default-features = false } bytes = "1.0" -hyper-tls = { version = "0.5.0", optional = true } +hyper-tls = { version = "0.6.0", optional = true } tokio-native-tls = { version = "0.3.0", optional = true } native-tls = { version = "0.2", optional = true } openssl = { version = "0.10", optional = true } tokio-openssl = { version = "0.6", optional = true } -tokio-rustls = { version = "0.22", optional = true } -hyper-rustls = { version = "0.22", optional = true } - -webpki = { version = "0.21", optional = true } -rustls-native-certs = { version = "0.5.0", optional = true } -webpki-roots = { version = "0.21.0", optional = true } -headers = "0.3" +tokio-rustls = { version = "0.26", optional = true } +hyper-rustls = { version = "0.27", optional = true } +webpki = { version = "0.22", optional = true } +rustls-native-certs = { version = "0.7.0", optional = true } +webpki-roots = { version = "0.26.0", optional = true } +headers = "0.4" +hyper-util = "0.1.3" [dev-dependencies] tokio = { version = "1.0", features = ["full"] } -hyper = { version = "0.14", features = ["client", "http1", "tcp"] } +hyper = { version = "1", features = ["client", "http1"] } [features] openssl-tls = ["openssl", "tokio-openssl"] diff --git a/src/lib.rs b/src/lib.rs index e75c830..dabd4bc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -62,11 +62,7 @@ use hyper::{service::Service, Uri}; use futures_util::future::TryFutureExt; use std::{fmt, io, sync::Arc}; -use std::{ - future::Future, - pin::Pin, - task::{Context, Poll}, -}; +use std::{future::Future, pin::Pin}; pub use stream::ProxyStream; use tokio::io::{AsyncRead, AsyncWrite}; @@ -430,19 +426,17 @@ where type Error = io::Error; type Future = Pin> + Send>>; - fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { - match self.connector.poll_ready(cx) { - Poll::Ready(Ok(())) => Poll::Ready(Ok(())), - Poll::Ready(Err(e)) => Poll::Ready(Err(io_err(e.into()))), - Poll::Pending => Poll::Pending, - } - } - - fn call(&mut self, uri: Uri) -> Self::Future { + fn call(&self, uri: Uri) -> Self::Future { if let (Some(p), Some(host)) = (self.match_proxy(&uri), uri.host()) { if uri.scheme() == Some(&http::uri::Scheme::HTTPS) || p.force_connect { let host = host.to_owned(); - let port = uri.port_u16().unwrap_or(if uri.scheme() == Some(&http::uri::Scheme::HTTP) { 80 } else { 443 }); + let port = + uri.port_u16() + .unwrap_or(if uri.scheme() == Some(&http::uri::Scheme::HTTP) { + 80 + } else { + 443 + }); let tunnel = tunnel::new(&host, port, &p.headers); let connection = proxy_dst(&uri, &p.uri).map(|proxy_url| self.connector.call(proxy_url)); diff --git a/src/stream.rs b/src/stream.rs index 4f45be6..a7c3df1 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -1,6 +1,7 @@ use std::io; use std::pin::Pin; use std::task::{Context, Poll}; +use hyper_util::client::legacy::connect::{Connected, Connection}; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; #[cfg(feature = "rustls-base")] @@ -12,7 +13,6 @@ use tokio_native_tls::TlsStream; #[cfg(feature = "openssl-tls")] use tokio_openssl::SslStream as OpenSslStream; -use hyper::client::connect::{Connected, Connection}; #[cfg(feature = "rustls-base")] pub type TlsStream = RustlsStream;