Commit
Author: mdecimus [mauro@stalw.art]
Hash: b0a5a0900d1a7a19341910ceeb476ed4b10c8713
Timestamp: Sun, 11 Aug 2024 18:01:23 +0000 (2 months ago)

+6 -5 +/-2 browse
DNS lookup limit being hit too early during SPF verification (fixes #35)
1diff --git a/resources/spf/basic.yml b/resources/spf/basic.yml
2index ff26b09..ca3edcd 100644
3--- a/resources/spf/basic.yml
4+++ b/resources/spf/basic.yml
5 @@ -84,8 +84,8 @@ tests:
6
7 name: DNS Lookup Limits
8 records:
9- spf: ok.test.org v=spf1 a:t1.org a:t2.org a:t3.org a:t4.org a:t5.org a:t6.org a:t7.org a:t8.org a:t9.org ~all
10- spf: err.test.org v=spf1 a:t1.org a:t2.org a:t3.org a:t4.org a:t5.org a:t6.org a:t7.org a:t8.org a:t9.org a:t10.org ~all
11+ spf: ok.test.org v=spf1 a:t1.org a:t2.org a:t3.org a:t4.org a:t5.org a:t6.org a:t7.org a:t8.org a:t9.org a:t10.org ~all
12+ spf: err.test.org v=spf1 a:t1.org a:t2.org a:t3.org a:t4.org a:t5.org a:t6.org a:t7.org a:t8.org a:t9.org a:t10.org a:t11.org ~all
13 spf: inc1.org v=spf1 include:inc2.org ~all
14 spf: inc2.org v=spf1 include:inc3.org ~all
15 spf: inc3.org v=spf1 include:inc4.org ~all
16 @@ -96,7 +96,8 @@ records:
17 spf: inc8.org v=spf1 include:inc9.org ~all
18 spf: inc9.org v=spf1 include:inc10.org ~all
19 spf: inc10.org v=spf1 include:inc11.org ~all
20- spf: inc11.org v=spf1 ~all
21+ spf: inc11.org v=spf1 include:inc12.org ~all
22+ spf: inc12.org v=spf1 ~all
23 spf: mx.test.org v=spf1 mx -all
24 spf: ptr.test.org v=spf1 ptr:test.org -all
25 mx: mx.test.org 10.0.0.1,10.0.0.2,10.0.0.3,10.0.0.4,10.0.0.5,10.0.0.6,10.0.0.7,10.0.0.8,10.0.0.9,10.0.0.10,10.0.0.11
26 diff --git a/src/spf/verify.rs b/src/spf/verify.rs
27index 0d1d7ec..9bc781b 100644
28--- a/src/spf/verify.rs
29+++ b/src/spf/verify.rs
30 @@ -490,7 +490,7 @@ impl LookupLimit {
31
32 #[inline(always)]
33 fn can_lookup(&mut self) -> bool {
34- if self.num_lookups < 10 && self.timer.elapsed().as_secs() < 20 {
35+ if self.num_lookups <= 10 && self.timer.elapsed().as_secs() < 20 {
36 self.num_lookups += 1;
37 true
38 } else {
39 @@ -663,7 +663,7 @@ mod test {
40 assert_eq!(
41 output.result(),
42 result,
43- "Failed for {test_name:?}, test {test_num}.",
44+ "Failed for {test_name:?}, test {test_num}, ehlo: {helo}, mail-from: {mail_from}.",
45 );
46
47 if !exp.is_empty() {