From 5853970c0f7b1ea25dc9affacfdc8b929f20cf88 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Fri, 4 Oct 2024 11:36:11 +0200 Subject: [PATCH] spf: add basic support for the exists mechanism --- crates/kumo-spf/src/record.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/kumo-spf/src/record.rs b/crates/kumo-spf/src/record.rs index 8400686e..50a0bbac 100644 --- a/crates/kumo-spf/src/record.rs +++ b/crates/kumo-spf/src/record.rs @@ -234,7 +234,18 @@ impl Directive { } } } - _ => todo!("evaluate directive {self:?}"), + Mechanism::Exists { domain } => { + let domain = cx.domain(Some(domain))?; + match resolver.lookup_ip(&domain).await { + Ok(ips) => ips.iter().any(|ip| ip.is_ipv4()), + Err(err) => { + return Err(SpfResult { + disposition: SpfDisposition::TempError, + context: format!("error looking up IP for {domain}: {err}"), + }) + } + } + } }; Ok(match matched {