From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 95BBA1FF173 for ; Mon, 13 Jan 2025 15:43:34 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 95D162E3B; Mon, 13 Jan 2025 15:43:16 +0100 (CET) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Mon, 13 Jan 2025 15:42:22 +0100 Message-Id: <20250113144226.467408-2-c.ebner@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250113144226.467408-1-c.ebner@proxmox.com> References: <20250113144226.467408-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.028 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH v2 proxmox 1/1] http: client: make https connector generic over resolver X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Allow to instantiate a `HttpsConnector` not using the default `getaddrinfo` based `GaiResolver` for domain name resolution, but rather a custom resolver implementing the required traits. The usecase for this is to swap out the DNS resolver for the statically linked proxmox-backup-client binary, where the glibc dependency is problematic because of possible ABI incompatibility. Adds tower-service as cargo workspace dependency and build dependency to debian/control. Signed-off-by: Christian Ebner --- changes since version 1: - no changes proxmox-http/Cargo.toml | 1 + proxmox-http/debian/control | 6 ++++-- proxmox-http/src/client/connector.rs | 17 ++++++++++++----- proxmox-http/src/client/simple.rs | 3 ++- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/proxmox-http/Cargo.toml b/proxmox-http/Cargo.toml index c8c963f7..6bfb1413 100644 --- a/proxmox-http/Cargo.toml +++ b/proxmox-http/Cargo.toml @@ -22,6 +22,7 @@ openssl = { version = "0.10", optional = true } serde_json = { workspace = true, optional = true } tokio = { workspace = true, features = [], optional = true } tokio-openssl = { workspace = true, optional = true } +tower-service.workspace = true ureq = { version = "2.4", features = ["native-certs", "native-tls"], optional = true, default-features = false } url = { workspace = true, optional = true } diff --git a/proxmox-http/debian/control b/proxmox-http/debian/control index bd5ad8df..ead7a223 100644 --- a/proxmox-http/debian/control +++ b/proxmox-http/debian/control @@ -6,7 +6,8 @@ Build-Depends: debhelper-compat (= 13), cargo:native , rustc:native (>= 1.80) , libstd-rust-dev , - librust-anyhow-1+default-dev + librust-anyhow-1+default-dev , + librust-tower-service-0.3+default-dev Maintainer: Proxmox Support Team Standards-Version: 4.7.0 Vcs-Git: git://git.proxmox.com/git/proxmox.git @@ -20,7 +21,8 @@ Architecture: any Multi-Arch: same Depends: ${misc:Depends}, - librust-anyhow-1+default-dev + librust-anyhow-1+default-dev, + librust-tower-service-0.3+default-dev Suggests: librust-proxmox-http+client-dev (= ${binary:Version}), librust-proxmox-http+client-sync-dev (= ${binary:Version}), diff --git a/proxmox-http/src/client/connector.rs b/proxmox-http/src/client/connector.rs index 63b9d10c..c0435c60 100644 --- a/proxmox-http/src/client/connector.rs +++ b/proxmox-http/src/client/connector.rs @@ -6,6 +6,7 @@ use std::task::{Context, Poll}; use futures::*; use http::Uri; +use hyper::client::connect::dns::Name; use hyper::client::HttpConnector; use openssl::ssl::SslConnector; use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; @@ -23,8 +24,8 @@ use crate::{RateLimitedStream, ShareableRateLimit}; type SharedRateLimit = Arc; #[derive(Clone)] -pub struct HttpsConnector { - connector: HttpConnector, +pub struct HttpsConnector { + connector: HttpConnector, ssl_connector: Arc, proxy: Option, tcp_keepalive: u32, @@ -32,9 +33,9 @@ pub struct HttpsConnector { write_limiter: Option, } -impl HttpsConnector { +impl HttpsConnector { pub fn with_connector( - mut connector: HttpConnector, + mut connector: HttpConnector, ssl_connector: SslConnector, tcp_keepalive: u32, ) -> Self { @@ -122,7 +123,13 @@ impl HttpsConnector { } } -impl hyper::service::Service for HttpsConnector { +impl hyper::service::Service for HttpsConnector +where + T: tower_service::Service + Clone + Send + Sync + 'static, + T::Future: Send, + T::Error: Into>, + T::Response: std::iter::Iterator, +{ type Response = MaybeTlsStream>; type Error = Error; #[allow(clippy::type_complexity)] diff --git a/proxmox-http/src/client/simple.rs b/proxmox-http/src/client/simple.rs index 062889ac..cb8bb777 100644 --- a/proxmox-http/src/client/simple.rs +++ b/proxmox-http/src/client/simple.rs @@ -8,6 +8,7 @@ use futures::*; #[cfg(all(feature = "client-trait", feature = "proxmox-async"))] use http::header::HeaderName; use http::{HeaderValue, Request, Response}; +use hyper::client::connect::dns::GaiResolver; use hyper::client::Client as HyperClient; use hyper::client::HttpConnector; use hyper::Body; @@ -18,7 +19,7 @@ use crate::HttpOptions; /// Asynchronous HTTP client implementation pub struct Client { - client: HyperClient, + client: HyperClient, Body>, options: HttpOptions, } -- 2.39.5 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel