spf: add basic support for the exists mechanism

This commit is contained in:
Dirkjan Ochtman
2024-10-12 08:00:15 -07:00
committed by Wez Furlong
parent 487a45c9ff
commit 5853970c0f
+12 -1
View File
@@ -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 {