From 79c609e4f1019399c3158f3562e02caa68c89f6d Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 8 Aug 2022 09:23:55 -0400 Subject: [PATCH] arti: Add a feature flag for dns-proxy. It remains on-by-default, so users shouldn't notice a difference, but it may help when we want to save a few bytes of binary size. Closes #532 --- crates/arti/Cargo.toml | 7 ++++--- crates/arti/src/lib.rs | 10 ++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/arti/Cargo.toml b/crates/arti/Cargo.toml index 8b309c3a2..a71309a7f 100644 --- a/crates/arti/Cargo.toml +++ b/crates/arti/Cargo.toml @@ -12,11 +12,12 @@ categories = ["command-line-utilities", "cryptography"] repository = "https://gitlab.torproject.org/tpo/core/arti.git/" [features] -default = ["tokio", "native-tls"] +default = ["tokio", "native-tls", "dns-proxy"] -full = ["async-std", "tokio", "native-tls", "journald", "arti-client/full"] +full = ["async-std", "tokio", "native-tls", "journald", "arti-client/full", "dns-proxy"] async-std = ["arti-client/async-std", "tor-rtcompat/async-std", "async-ctrlc", "once_cell"] +dns-proxy = ["trust-dns-proto"] tokio = ["tokio-crate", "arti-client/tokio", "tor-rtcompat/tokio"] native-tls = ["arti-client/native-tls", "tor-rtcompat/native-tls"] rustls = ["arti-client/rustls", "tor-rtcompat/rustls"] @@ -57,7 +58,7 @@ tracing = "0.1.18" tracing-appender = "0.2.0" tracing-journald = { version = "0.3.0", optional = true } tracing-subscriber = { version = "0.3.0", features = ["env-filter"] } -trust-dns-proto = "0.21.1" +trust-dns-proto = { version = "0.21.1", optional = true } [dev-dependencies] itertools = "0.10.1" diff --git a/crates/arti/src/lib.rs b/crates/arti/src/lib.rs index d5269f292..68925c0ae 100644 --- a/crates/arti/src/lib.rs +++ b/crates/arti/src/lib.rs @@ -52,6 +52,8 @@ //! (default) //! * `journald` -- Build with support for logging to the `journald` logging //! backend (available as part of systemd.) +//! * `dns-proxy` (default) -- Build with support for proxying certain simple +//! DNS queries over the Tor network. //! //! * `full` -- Build with all features above, along with all stable additive //! features from other arti crates. (This does not include experimental @@ -150,6 +152,7 @@ #![allow(clippy::print_stdout)] pub mod cfg; +#[cfg(feature = "dns-proxy")] pub mod dns; pub mod exit; pub mod logging; @@ -246,6 +249,7 @@ pub async fn run( })); } + #[cfg(feature = "dns-proxy")] if dns_port != 0 { let runtime = runtime.clone(); let client = client.isolated_client(); @@ -255,6 +259,12 @@ pub async fn run( })); } + #[cfg(not(feature = "dns-proxy"))] + if dns_port != 0 { + warn!("Tried to specify a DNS proxy port, but Arti was built without dns-proxy support."); + return Ok(()); + } + if proxy.is_empty() { warn!("No proxy port set; specify -p PORT (for `socks_port`) or -d PORT (for `dns_port`). Alternatively, use the `socks_port` or `dns_port` configuration option."); return Ok(());