Commit
Author: Kevin Schoon [me@kevinschoon.com]
Hash: 74f7a220b182583a35245c811bc45827f02f742c
Timestamp: Sat, 05 Oct 2024 09:22:24 +0000 (2 months ago)

+60 -6 +/-1 browse
log spf and dkim failures
1diff --git a/maitred/src/validation.rs b/maitred/src/validation.rs
2index 90525ed..12e65c5 100644
3--- a/maitred/src/validation.rs
4+++ b/maitred/src/validation.rs
5 @@ -9,11 +9,35 @@ pub(crate) struct Validation<'a>(pub MutexGuard<'a, Resolver>);
6 impl Validation<'_> {
7 pub async fn verify_dkim(&self, message: &[u8]) -> bool {
8 let authenticated = AuthenticatedMessage::parse(message).unwrap();
9- let passed = self.0.verify_dkim(&authenticated).await.iter().all(|s| {
10- tracing::info!("{:?}", s);
11- matches!(s.result(), DkimResult::Pass)
12- });
13- passed
14+ self.0.verify_dkim(&authenticated).await.iter().all(|s| {
15+ match s.result() {
16+ DkimResult::Pass => {
17+ tracing::info!("DKIM Passed");
18+ true
19+ }
20+ DkimResult::Neutral(error) => {
21+ tracing::info!("DKIM Neutral: {}", error);
22+ false
23+ }
24+ DkimResult::Fail(error) => {
25+ tracing::info!("DKIM Failed: {}", error);
26+ false
27+ }
28+ DkimResult::PermError(error) => {
29+ tracing::info!("DKIM Permanent Error: {}", error);
30+ false
31+ }
32+ DkimResult::TempError(error) => {
33+ // TODO: queued retry?
34+ tracing::info!("DKIM Temporary Error: {}", error);
35+ false
36+ }
37+ DkimResult::None => {
38+ tracing::warn!("No DKIM Result");
39+ false
40+ }
41+ }
42+ })
43 }
44
45 pub async fn verify_spf(
46 @@ -27,6 +51,36 @@ impl Validation<'_> {
47 .0
48 .verify_spf(ip, helo_domain, host_domain, sender)
49 .await;
50- matches!(output.result(), mail_auth::SpfResult::Pass)
51+ match output.result() {
52+ mail_auth::SpfResult::Pass => {
53+ tracing::info!("SPF Passed");
54+ true
55+ }
56+ mail_auth::SpfResult::Fail => {
57+ tracing::info!("SPF Failed");
58+ false
59+ }
60+ mail_auth::SpfResult::SoftFail => {
61+ tracing::info!("SPF Soft Failure");
62+ false
63+ }
64+ mail_auth::SpfResult::Neutral => {
65+ tracing::info!("SPF Neutral");
66+ false
67+ }
68+ mail_auth::SpfResult::TempError => {
69+ // TODO Queued retry?
70+ tracing::info!("SPF Temporary Error");
71+ false
72+ }
73+ mail_auth::SpfResult::PermError => {
74+ tracing::info!("SPF Permanent Error");
75+ false
76+ }
77+ mail_auth::SpfResult::None => {
78+ tracing::info!("No SPF Result");
79+ false
80+ }
81+ }
82 }
83 }