mirror of
https://github.com/chatmail/relay.git
synced 2026-08-10 18:40:51 +00:00
fix(resolver): disable negative caching (#170)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user