From 87e26a8aaa6955342a0645ec22809a89d7063542 Mon Sep 17 00:00:00 2001 From: YX Hao Date: Sat, 25 Jun 2022 21:19:58 +0800 Subject: [PATCH 1/2] Mitigate warning on intentional unused variable --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 5a8e758..d693be5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -516,7 +516,7 @@ fn privdrop(config: &Config) -> Result<(), Error> { } #[cfg(not(target_family = "unix"))] -fn set_limits(config: &Config) -> Result<(), Error> { +fn set_limits(_config: &Config) -> Result<(), Error> { Ok(()) } From 4f99570f22c62866cdfee3cf970255d09430d764 Mon Sep 17 00:00:00 2001 From: YX Hao Date: Sat, 25 Jun 2022 21:29:13 +0800 Subject: [PATCH 2/2] Improve privdrop condition --- Cargo.toml | 2 +- src/main.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8fdf9ee..c7623ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,7 +57,7 @@ tokio = { version = "1.19.2", features = [ ] } toml = "0.5.9" -[target.'cfg(not(target_family = "windows"))'.dependencies] +[target.'cfg(target_family = "unix")'.dependencies] privdrop = "0.5.2" [dependencies.prometheus] diff --git a/src/main.rs b/src/main.rs index d693be5..d5d7796 100644 --- a/src/main.rs +++ b/src/main.rs @@ -62,7 +62,7 @@ use futures::prelude::*; use globals::*; use parking_lot::Mutex; use parking_lot::RwLock; -#[cfg(not(target_family = "windows"))] +#[cfg(target_family = "unix")] use privdrop::PrivDrop; use rand::prelude::*; use siphasher::sip128::SipHasher13; @@ -481,7 +481,7 @@ fn bind_listeners( Ok(sockets) } -#[cfg(not(target_family = "windows"))] +#[cfg(target_family = "unix")] fn privdrop(config: &Config) -> Result<(), Error> { let mut pd = PrivDrop::default(); if let Some(user) = &config.user { @@ -604,7 +604,7 @@ fn main() -> Result<(), Error> { runtime_builder.thread_name("encrypted-dns-"); let runtime = runtime_builder.build()?; - #[cfg(not(target_family = "windows"))] + #[cfg(target_family = "unix")] privdrop(&config)?; let key_cache_capacity = config.dnscrypt.key_cache_capacity;