From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 276B11FF16F for ; Tue, 14 Oct 2025 09:12:37 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0384521B0E; Tue, 14 Oct 2025 09:12:55 +0200 (CEST) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Tue, 14 Oct 2025 09:11:42 +0200 Message-ID: <20251014071221.454180-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.026 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com, mod.rs, config.rs] Subject: [pdm-devel] [PATCH datacenter-manager] ui: pbs wizard: strip http(s):// prefix on remote creation X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" by reusing our 'normalize_hostname' helper. Move that to the remote module, make it (crate) public, and use it for the case when we don't have a nodes list (which is only pbs at the moment). This strips the 'http(s)://' prefix when submitting the remote to the backend, and preventing the 'invalid uri character' error there. Reported in the forum: https://forum.proxmox.com/threads/cant-add-proxmox-backup-server-node.173560/ Signed-off-by: Dominik Csapak --- ui/src/remotes/config.rs | 4 +++- ui/src/remotes/mod.rs | 15 +++++++++++++++ ui/src/remotes/wizard_page_connect.rs | 16 ++-------------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/ui/src/remotes/config.rs b/ui/src/remotes/config.rs index c8c7815d..6e9ae490 100644 --- a/ui/src/remotes/config.rs +++ b/ui/src/remotes/config.rs @@ -7,6 +7,7 @@ use anyhow::Error; use proxmox_schema::property_string::PropertyString; use crate::remotes::edit_remote::EditRemote; +use crate::remotes::normalize_hostname; //use pwt::widget::form::{Field, FormContext, InputType}; use pdm_api_types::remotes::Remote; @@ -50,8 +51,9 @@ async fn delete_item(key: Key) -> Result<(), Error> { pub async fn create_remote(mut data: Value, remote_type: RemoteType) -> Result<(), Error> { if data.get("nodes").is_none() { + let hostname = data["hostname"].as_str().unwrap_or_default().to_string(); let nodes = vec![PropertyString::new(NodeUrl { - hostname: data["hostname"].as_str().unwrap_or_default().to_string(), + hostname: normalize_hostname(hostname), fingerprint: data["fingerprint"].as_str().map(|fp| fp.to_string()), })]; data["nodes"] = serde_json::to_value(nodes)?; diff --git a/ui/src/remotes/mod.rs b/ui/src/remotes/mod.rs index 83b3331b..fa091753 100644 --- a/ui/src/remotes/mod.rs +++ b/ui/src/remotes/mod.rs @@ -57,3 +57,18 @@ pub fn system_configuration() -> Html { NavigationContainer::new().with_child(panel).into() } + +/// normalize hostname for use in config +pub(crate) fn normalize_hostname(hostname: String) -> String { + let mut result = hostname; + if let Some(hostname) = result.strip_prefix("http://") { + result = hostname.to_string(); + } + if let Some(hostname) = result.strip_prefix("https://") { + result = hostname.to_string(); + } + if let Some(hostname) = result.strip_suffix("/") { + result = hostname.to_string(); + } + result +} diff --git a/ui/src/remotes/wizard_page_connect.rs b/ui/src/remotes/wizard_page_connect.rs index bc45df61..9f5ba3ff 100644 --- a/ui/src/remotes/wizard_page_connect.rs +++ b/ui/src/remotes/wizard_page_connect.rs @@ -18,6 +18,8 @@ use pdm_api_types::remotes::{RemoteType, TlsProbeOutcome}; use pdm_api_types::CERT_FINGERPRINT_SHA256_SCHEMA; use proxmox_acme_api::CertificateInfo; +use crate::remotes::normalize_hostname; + #[derive(Clone, PartialEq, Properties)] #[builder] pub struct WizardPageConnect { @@ -278,20 +280,6 @@ fn call_on_connect_change(props: &WizardPageConnect, certificate_info: Option String { - let mut result = hostname; - if let Some(hostname) = result.strip_prefix("http://") { - result = hostname.to_string(); - } - if let Some(hostname) = result.strip_prefix("https://") { - result = hostname.to_string(); - } - if let Some(hostname) = result.strip_suffix("/") { - result = hostname.to_string(); - } - result -} - fn rows() -> Vec { let render_date = |_name: &str, value: &Value, _record: &Value| -> Html { match value.as_i64() { -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel