From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 48FEE1FF161 for ; Tue, 13 Aug 2024 12:57:00 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A43943F888; Tue, 13 Aug 2024 12:57:13 +0200 (CEST) From: Maximiliano Sandoval To: pbs-devel@lists.proxmox.com Date: Tue, 13 Aug 2024 12:56:59 +0200 Message-Id: <20240813105709.320119-2-m.sandoval@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240813105709.320119-1-m.sandoval@proxmox.com> References: <20240813105709.320119-1-m.sandoval@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.115 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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pbs-devel] [PATCH proxmox 02/12] dns-api: remove lazy-static dependency 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: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Signed-off-by: Maximiliano Sandoval --- proxmox-dns-api/Cargo.toml | 2 +- proxmox-dns-api/debian/control | 2 -- proxmox-dns-api/src/resolv_conf.rs | 17 ++++++----------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/proxmox-dns-api/Cargo.toml b/proxmox-dns-api/Cargo.toml index 406c9466..98045b34 100644 --- a/proxmox-dns-api/Cargo.toml +++ b/proxmox-dns-api/Cargo.toml @@ -7,11 +7,11 @@ license.workspace = true repository.workspace = true exclude.workspace = true description = "DNS Management API implementation" +rust-version.workspace = true [dependencies] anyhow.workspace = true const_format.workspace = true -lazy_static.workspace = true regex.workspace = true serde = { workspace = true, features = ["derive"] } diff --git a/proxmox-dns-api/debian/control b/proxmox-dns-api/debian/control index e3923623..e1c32dcf 100644 --- a/proxmox-dns-api/debian/control +++ b/proxmox-dns-api/debian/control @@ -8,7 +8,6 @@ Build-Depends: debhelper (>= 12), libstd-rust-dev , librust-anyhow-1+default-dev , librust-const-format-0.2+default-dev , - librust-lazy-static-1+default-dev (>= 1.4-~~) , librust-proxmox-config-digest-0.1+default-dev , librust-proxmox-schema-3+api-macro-dev (>= 3.1.1-~~) , librust-proxmox-schema-3+api-types-dev (>= 3.1.1-~~) , @@ -31,7 +30,6 @@ Depends: librust-anyhow-1+default-dev, librust-const-format-0.2+default-dev, librust-lazy-static-1+default-dev (>= 1.4-~~), - librust-proxmox-config-digest-0.1+default-dev, librust-proxmox-schema-3+api-macro-dev (>= 3.1.1-~~), librust-proxmox-schema-3+api-types-dev (>= 3.1.1-~~), librust-proxmox-schema-3+default-dev (>= 3.1.1-~~), diff --git a/proxmox-dns-api/src/resolv_conf.rs b/proxmox-dns-api/src/resolv_conf.rs index 1b09d07f..32698913 100644 --- a/proxmox-dns-api/src/resolv_conf.rs +++ b/proxmox-dns-api/src/resolv_conf.rs @@ -1,9 +1,7 @@ -use std::sync::Arc; -use std::sync::Mutex; +use std::sync::{Arc, LazyLock, Mutex}; use anyhow::Error; use const_format::concatcp; -use lazy_static::lazy_static; use proxmox_config_digest::ConfigDigest; use regex::Regex; @@ -34,11 +32,10 @@ pub fn read_etc_resolv_conf( let data = String::from_utf8(raw)?; - lazy_static! { - static ref DOMAIN_REGEX: Regex = Regex::new(r"^\s*(?:search|domain)\s+(\S+)\s*").unwrap(); - static ref SERVER_REGEX: Regex = - Regex::new(concatcp!(r"^\s*nameserver\s+(", IPRE_STR, r")\s*")).unwrap(); - } + static DOMAIN_REGEX: LazyLock = + LazyLock::new(|| Regex::new(r"^\s*(?:search|domain)\s+(\S+)\s*").unwrap()); + static SERVER_REGEX: LazyLock = + LazyLock::new(|| Regex::new(concatcp!(r"^\s*nameserver\s+(", IPRE_STR, r")\s*")).unwrap()); let mut options = String::new(); @@ -78,9 +75,7 @@ pub fn update_dns( delete: Option>, digest: Option, ) -> Result<(), Error> { - lazy_static! { - static ref MUTEX: Arc> = Arc::new(Mutex::new(())); - } + static MUTEX: LazyLock>> = LazyLock::new(|| Arc::new(Mutex::new(()))); let _guard = MUTEX.lock(); -- 2.39.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel