From cf4e65c607fd3218b9a27d187c418ce648316dae Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 22 Sep 2025 18:54:32 +0000 Subject: [PATCH] Fix alternative resolver minimum TTL configuration. (fixes #176) Signed-off-by: Jason Volk --- src/service/resolver/dns.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/service/resolver/dns.rs b/src/service/resolver/dns.rs index 23be4647..945cacd1 100644 --- a/src/service/resolver/dns.rs +++ b/src/service/resolver/dns.rs @@ -34,16 +34,19 @@ type ResolvingResult = Result>; impl Resolver { pub(super) fn build(server: &Arc, cache: Arc) -> Result> { + let config = &server.config; + // Create the primary resolver. - let (conf, opts) = Self::configure(server)?; + let (conf, mut opts) = Self::configure(server)?; + opts.negative_min_ttl = Some(Duration::from_secs(config.dns_min_ttl_nxdomain)); + opts.positive_min_ttl = Some(Duration::from_secs(config.dns_min_ttl)); + opts.cache_size = config.dns_cache_entries.try_into()?; let resolver = Self::create(server, conf.clone(), opts.clone())?; // Create the passthru resolver with modified options. let (conf, mut opts) = (conf, opts); - opts.negative_min_ttl = None; - opts.negative_max_ttl = None; - opts.positive_min_ttl = None; - opts.positive_max_ttl = None; + opts.negative_min_ttl = Some(Duration::ZERO); + opts.positive_min_ttl = Some(Duration::ZERO); opts.cache_size = ResolverOpts::default().cache_size; let passthru = Arc::new(Passthru { resolver: Self::create(server, conf, opts)?, @@ -111,10 +114,7 @@ impl Resolver { fn configure_opts(server: &Arc, mut opts: ResolverOpts) -> ResolverOpts { let config = &server.config; - opts.cache_size = config.dns_cache_entries as usize; - opts.negative_min_ttl = Some(Duration::from_secs(config.dns_min_ttl_nxdomain)); opts.negative_max_ttl = Some(Duration::from_secs(60 * 60 * 24 * 30)); - opts.positive_min_ttl = Some(Duration::from_secs(config.dns_min_ttl)); opts.positive_max_ttl = Some(Duration::from_secs(60 * 60 * 24 * 7)); opts.timeout = Duration::from_secs(config.dns_timeout); opts.attempts = config.dns_attempts as usize;