public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dylan Whyte <d.whyte@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 2/4] fix #3296: node conf: add http_proxy to config
Date: Fri,  7 May 2021 12:53:01 +0200	[thread overview]
Message-ID: <20210507105303.7793-2-d.whyte@proxmox.com> (raw)
In-Reply-To: <20210507105303.7793-1-d.whyte@proxmox.com>

add http_proxy to server's node config, as well as functions for setting
retrieving

Signed-off-by: Dylan Whyte <d.whyte@proxmox.com>
---
 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<String>,
+
+    #[serde(skip_serializing_if = "Updater::is_empty")]
+    http_proxy: Option<String>,
 }
 
 impl NodeConfig {
@@ -137,6 +148,21 @@ impl NodeConfig {
         AcmeDomainIter::new(self)
     }
 
+    pub fn http_proxy(&self) -> Option<ProxyConfig> {
+        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<String>) {
+        self.http_proxy = http_proxy;
+    }
+
     /// Validate the configuration.
     pub fn validate(&self) -> Result<(), Error> {
         let mut domains = HashSet::new();
-- 
2.20.1





  reply	other threads:[~2021-05-07 10:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-07 10:53 [pbs-devel] [PATCH proxmox-backup 1/4] fix 3296: add api endpoint for set, get, rm proxy Dylan Whyte
2021-05-07 10:53 ` Dylan Whyte [this message]
2021-05-07 10:53 ` [pbs-devel] [PATCH proxmox-backup 3/4] fix #3296: use proxy for subscriptions Dylan Whyte
2021-05-10  6:44   ` Dietmar Maurer
2021-05-10  7:25   ` [pbs-devel] applied: " Dietmar Maurer
2021-05-07 10:53 ` [pbs-devel] [PATCH proxmox-backup 4/4] fix #3296: use proxy client to retrieve changelog Dylan Whyte
2021-05-10  7:25   ` [pbs-devel] applied: " Dietmar Maurer
2021-05-10  5:21 ` [pbs-devel] [PATCH proxmox-backup 1/4] fix 3296: add api endpoint for set, get, rm proxy Dietmar Maurer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210507105303.7793-2-d.whyte@proxmox.com \
    --to=d.whyte@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal