From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pbs-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id 3DC211FF167
	for <inbox@lore.proxmox.com>; Wed, 14 Aug 2024 09:19:52 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 340B7FB40;
	Wed, 14 Aug 2024 09:20:06 +0200 (CEST)
From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pbs-devel@lists.proxmox.com
Date: Wed, 14 Aug 2024 09:19:51 +0200
Message-Id: <20240814072001.53422-2-m.sandoval@proxmox.com>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <20240814072001.53422-1-m.sandoval@proxmox.com>
References: <20240814072001.53422-1-m.sandoval@proxmox.com>
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.112 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 v2 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
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox Backup Server development discussion
 <pbs-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pbs-devel-bounces@lists.proxmox.com
Sender: "pbs-devel" <pbs-devel-bounces@lists.proxmox.com>

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-dns-api/Cargo.toml         |  2 +-
 proxmox-dns-api/src/resolv_conf.rs | 17 ++++++-----------
 2 files changed, 7 insertions(+), 12 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/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<Regex> =
+        LazyLock::new(|| Regex::new(r"^\s*(?:search|domain)\s+(\S+)\s*").unwrap());
+    static SERVER_REGEX: LazyLock<Regex> =
+        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<Vec<DeletableResolvConfProperty>>,
     digest: Option<ConfigDigest>,
 ) -> Result<(), Error> {
-    lazy_static! {
-        static ref MUTEX: Arc<Mutex<()>> = Arc::new(Mutex::new(()));
-    }
+    static MUTEX: LazyLock<Arc<Mutex<()>>> = 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