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 22FBD7A4AC for ; Fri, 7 May 2021 12:59:03 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 18E2329C12 for ; Fri, 7 May 2021 12:58:33 +0200 (CEST) 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 id 0408729BF2 for ; Fri, 7 May 2021 12:58:32 +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 25FB146497 for ; Fri, 7 May 2021 12:53:18 +0200 (CEST) From: Dylan Whyte To: pbs-devel@lists.proxmox.com Date: Fri, 7 May 2021 12:53:01 +0200 Message-Id: <20210507105303.7793-2-d.whyte@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210507105303.7793-1-d.whyte@proxmox.com> References: <20210507105303.7793-1-d.whyte@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.171 Adjusted score from AWL reputation of From: address 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. [node.rs] Subject: [pbs-devel] [PATCH proxmox-backup 2/4] fix #3296: node conf: add http_proxy to config 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: Fri, 07 May 2021 10:59:03 -0000 add http_proxy to server's node config, as well as functions for setting retrieving Signed-off-by: Dylan Whyte --- src/config/node.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/config/node.rs b/src/config/node.rs index 6f48409f..e4bbc3e5 100644 --- a/src/config/node.rs +++ b/src/config/node.rs @@ -10,8 +10,12 @@ use proxmox::api::api; use proxmox::api::schema::{ApiStringFormat, Updater}; use proxmox::tools::fs::{replace_file, CreateOptions}; -use crate::api2::types::{AcmeDomain, AcmeAccountName, ACME_DOMAIN_PROPERTY_SCHEMA}; +use crate::api2::types::{AcmeDomain, + AcmeAccountName, + ACME_DOMAIN_PROPERTY_SCHEMA, + HTTP_PROXY_SCHEMA}; use crate::acme::AcmeClient; +use crate::tools::http::ProxyConfig; const CONF_FILE: &str = configdir!("/node.cfg"); const LOCK_FILE: &str = configdir!("/.node.lck"); @@ -88,6 +92,10 @@ pub struct AcmeConfig { schema: ACME_DOMAIN_PROPERTY_SCHEMA, optional: true, }, + http_proxy: { + schema: HTTP_PROXY_SCHEMA, + optional: true, + }, }, )] #[derive(Deserialize, Serialize, Updater)] @@ -111,6 +119,9 @@ pub struct NodeConfig { #[serde(skip_serializing_if = "Updater::is_empty")] acmedomain4: Option, + + #[serde(skip_serializing_if = "Updater::is_empty")] + http_proxy: Option, } impl NodeConfig { @@ -137,6 +148,21 @@ impl NodeConfig { AcmeDomainIter::new(self) } + pub fn http_proxy(&self) -> Option { + if let Some(http_proxy) = &self.http_proxy { + match ProxyConfig::parse_proxy_url(&http_proxy) { + Ok(proxy) => Some(proxy), + Err(_) => None, + } + } else { + None + } + } + + pub fn set_proxy(&mut self, http_proxy: Option) { + self.http_proxy = http_proxy; + } + /// Validate the configuration. pub fn validate(&self) -> Result<(), Error> { let mut domains = HashSet::new(); -- 2.20.1