fix(resolver): disable negative caching (#170)

This commit is contained in:
Andrey 0xdc09
2026-06-02 10:04:32 +00:00
committed by GitHub
parent 6d6517f8f3
commit 8a60245183
+9 -3
View File
@@ -1,8 +1,10 @@
use hickory_resolver::config::ResolverOpts;
use hickory_resolver::{TokioResolver, proto::dnssec::TrustAnchors};
use mailparse::MailAddr;
use std::path::PathBuf;
use std::str::FromStr;
use std::sync::Arc;
use std::time::Duration;
/// Extracts the first email address found in SMTP command or email header.
///
@@ -106,10 +108,14 @@ pub async fn log_eml(reason: &str, data: &[u8]) -> Result<PathBuf, crate::error:
/// Creates a DNS resolver with DNSSEC enabled and system configuration (resolv.conf).
pub fn build_resolver() -> Result<TokioResolver, crate::error::Error> {
let dns_resolver = TokioResolver::builder_tokio()?
let mut builder = TokioResolver::builder_tokio()?
// https://github.com/hickory-dns/hickory-dns/issues/3519
.with_trust_anchor(Arc::new(TrustAnchors::default()))
.build()?;
.with_trust_anchor(Arc::new(TrustAnchors::default()));
// disable negative caching to prevent possible federation problems
builder.options_mut().negative_max_ttl = Some(Duration::ZERO);
let dns_resolver = builder.build()?;
assert!(
dns_resolver.options().validate,