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)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id B50786C9F2 for ; Tue, 30 Mar 2021 16:48:18 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A8D502C399 for ; Tue, 30 Mar 2021 16:47:48 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 id 450432C391 for ; Tue, 30 Mar 2021 16:47:47 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 1374045975 for ; Tue, 30 Mar 2021 16:47:47 +0200 (CEST) From: Dylan Whyte To: pbs-devel@lists.proxmox.com Date: Tue, 30 Mar 2021 16:47:25 +0200 Message-Id: <20210330144725.7892-2-d.whyte@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210330144725.7892-1-d.whyte@proxmox.com> References: <20210330144725.7892-1-d.whyte@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.016 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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. [http.rs, apt.rs, proxmox.com] Subject: [pbs-devel] [PATCH v2 proxmox-backup 2/2] tools-http: Add proxy option for get_string 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: , X-List-Received-Date: Tue, 30 Mar 2021 14:48:18 -0000 Adds a proxy argument to the get_string function, which will use the proxy connector if it has a value. Also updates calls to the function to avoid breakages Signed-off-by: Dylan Whyte --- I decided to add this in with the fix, although it currently has no effect. Again, once the situation with the administration config file is understood, I can get the proxy from that. src/api2/node/apt.rs | 6 ++++-- src/tools/http.rs | 12 ++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/api2/node/apt.rs b/src/api2/node/apt.rs index e77b89fa..3395fe1d 100644 --- a/src/api2/node/apt.rs +++ b/src/api2/node/apt.rs @@ -197,7 +197,8 @@ fn apt_get_changelog( let changelog_url = &pkg_info[0].change_log_url; // FIXME: use 'apt-get changelog' for proxmox packages as well, once repo supports it if changelog_url.starts_with("http://download.proxmox.com/") { - let changelog = crate::tools::runtime::block_on(http::get_string(changelog_url, None)) + // FIXME: get http_proxy from config file + let changelog = crate::tools::runtime::block_on(http::get_string(changelog_url, None, None)) .map_err(|err| format_err!("Error downloading changelog from '{}': {}", changelog_url, err))?; Ok(json!(changelog)) @@ -221,7 +222,8 @@ fn apt_get_changelog( auth_header.insert("Authorization".to_owned(), format!("Basic {}", base64::encode(format!("{}:{}", key, id)))); - let changelog = crate::tools::runtime::block_on(http::get_string(changelog_url, Some(&auth_header))) + // FIXME: get http_proxy from config file + let changelog = crate::tools::runtime::block_on(http::get_string(changelog_url, Some(&auth_header), None)) .map_err(|err| format_err!("Error downloading changelog from '{}': {}", changelog_url, err))?; Ok(json!(changelog)) diff --git a/src/tools/http.rs b/src/tools/http.rs index 8d940d01..ea32946c 100644 --- a/src/tools/http.rs +++ b/src/tools/http.rs @@ -29,7 +29,10 @@ lazy_static! { }; } -pub async fn get_string(uri: &str, extra_headers: Option<&HashMap>) -> Result { +pub async fn get_string(uri: &str, + extra_headers: Option<&HashMap>, + proxy: Option + ) -> Result { let mut request = Request::builder() .method("GET") .uri(uri) @@ -43,7 +46,12 @@ pub async fn get_string(uri: &str, extra_headers: Option<&HashMap