From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id B2B6E96FD4 for ; Fri, 27 Jan 2023 11:25:09 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 967F270BE for ; Fri, 27 Jan 2023 11:25:09 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 27 Jan 2023 11:25:08 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 41F5D467A2 for ; Fri, 27 Jan 2023 11:25:08 +0100 (CET) Date: Fri, 27 Jan 2023 11:25:01 +0100 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20230119104041.264052-1-l.wagner@proxmox.com> In-Reply-To: <20230119104041.264052-1-l.wagner@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.16.0 (https://github.com/astroidmail/astroid) Message-Id: <1674815039.xmuw5w7ibo.astroid@yuna.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.131 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [subscription.rs, mirror.rs, proxmox.com] Subject: [pve-devel] applied-series: [PATCH proxmox-offline-mirror 1/2] fix #4445: mirror: subscription: add proxy support X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jan 2023 10:25:09 -0000 On January 19, 2023 11:40 am, Lukas Wagner wrote: > This commit adds support for HTTP proxies, configurable via the > ALL_PROXY environment variable. >=20 > For example: > $ ALL_PROXY=3D"localhost:3128" proxmox-offline-mirror mirror <...> >=20 > Note: `ureq` seems to use HTTP CONNECT for *all* connections, including > HTTP on port 80. Proxies need to be configured to allow that - Squid by > default allows CONNECT only for HTTPS on port 443. I wonder how much work it would be to change that upstream? IIRC we also contributed HTTPS_PROXY support to ureq, and this is not the only place whe= re we use it and want proper proxy support.. > Signed-off-by: Lukas Wagner > --- > src/mirror.rs | 3 ++- > src/subscription.rs | 13 +++++++------ > 2 files changed, 9 insertions(+), 7 deletions(-) >=20 > diff --git a/src/mirror.rs b/src/mirror.rs > index 86974b7..787e223 100644 > --- a/src/mirror.rs > +++ b/src/mirror.rs > @@ -9,7 +9,7 @@ use anyhow::{bail, format_err, Error}; > use flate2::bufread::GzDecoder; > use globset::{Glob, GlobSet, GlobSetBuilder}; > use nix::libc; > -use proxmox_http::{client::sync::Client, HttpClient, HttpOptions}; > +use proxmox_http::{client::sync::Client, HttpClient, HttpOptions, ProxyC= onfig}; > use proxmox_sys::fs::file_get_contents; > =20 > use crate::{ > @@ -64,6 +64,7 @@ impl TryInto for MirrorConfig { > =20 > let options =3D HttpOptions { > user_agent: Some("proxmox-offline-mirror 0.1".to_string()), > + proxy_config: ProxyConfig::from_proxy_env()?, > ..Default::default() > }; // TODO actually read version ;) > =20 > diff --git a/src/subscription.rs b/src/subscription.rs > index 42794fe..d186a95 100644 > --- a/src/subscription.rs > +++ b/src/subscription.rs > @@ -1,7 +1,7 @@ > use anyhow::{bail, format_err, Error}; > =20 > use proxmox_http::client::sync::Client; > -use proxmox_http::{HttpClient, HttpOptions}; > +use proxmox_http::{HttpClient, HttpOptions, ProxyConfig}; > use proxmox_subscription::SubscriptionStatus; > use proxmox_subscription::{ > sign::{SignRequest, SignedResponse}, > @@ -15,12 +15,13 @@ const PRODUCT_URL: &str =3D "-"; > // TODO add version? > const USER_AGENT: &str =3D "proxmox-offline-mirror"; > =20 > -fn client() -> Client { > +fn client() -> Result { > let options =3D HttpOptions { > user_agent: Some(USER_AGENT.to_string()), > + proxy_config: ProxyConfig::from_proxy_env()?, > ..Default::default() > }; > - Client::new(options) > + Ok(Client::new(options)) > } > =20 > pub fn extract_mirror_key(keys: &[SubscriptionKey]) -> Result { > @@ -61,7 +62,7 @@ pub fn refresh_offline_keys( > key.key.clone(), > key.server_id.clone(), > PRODUCT_URL.to_string(), > - client(), > + client()?, > ) { > errors =3D true; > eprintln!("Failed to refresh subscription key {} - {}", key.= key, err); > @@ -74,7 +75,7 @@ pub fn refresh_offline_keys( > mirror_key: mirror_key.into(), > blobs: offline_keys.into_iter().map(|k| k.into()).collect(), > }; > - let res =3D client().post( > + let res =3D client()?.post( > "https://shop.proxmox.com/proxmox-subscription/sign", > Some(serde_json::to_vec(&request)?.as_slice()), > Some("text/json"), > @@ -98,6 +99,6 @@ pub fn refresh_mirror_key(mirror_key: SubscriptionKey) = -> Result mirror_key.key, > mirror_key.server_id, > PRODUCT_URL.to_string(), > - client(), > + client()?, > ) > } > --=20 > 2.30.2 >=20 >=20 >=20 > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >=20 >=20 >=20