Skip to content

Commit

Permalink
DNS lookup limit being hit too early during SPF verification (fixes #35
Browse files Browse the repository at this point in the history
)
  • Loading branch information
mdecimus committed Aug 11, 2024
1 parent 5b57af6 commit b0a5a09
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions resources/spf/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ tests:

name: DNS Lookup Limits
records:
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
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
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
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
spf: inc1.org v=spf1 include:inc2.org ~all
spf: inc2.org v=spf1 include:inc3.org ~all
spf: inc3.org v=spf1 include:inc4.org ~all
Expand All @@ -96,7 +96,8 @@ records:
spf: inc8.org v=spf1 include:inc9.org ~all
spf: inc9.org v=spf1 include:inc10.org ~all
spf: inc10.org v=spf1 include:inc11.org ~all
spf: inc11.org v=spf1 ~all
spf: inc11.org v=spf1 include:inc12.org ~all
spf: inc12.org v=spf1 ~all
spf: mx.test.org v=spf1 mx -all
spf: ptr.test.org v=spf1 ptr:test.org -all
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
Expand Down
4 changes: 2 additions & 2 deletions src/spf/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ impl LookupLimit {

#[inline(always)]
fn can_lookup(&mut self) -> bool {
if self.num_lookups < 10 && self.timer.elapsed().as_secs() < 20 {
if self.num_lookups <= 10 && self.timer.elapsed().as_secs() < 20 {
self.num_lookups += 1;
true
} else {
Expand Down Expand Up @@ -663,7 +663,7 @@ mod test {
assert_eq!(
output.result(),
result,
"Failed for {test_name:?}, test {test_num}.",
"Failed for {test_name:?}, test {test_num}, ehlo: {helo}, mail-from: {mail_from}.",
);

if !exp.is_empty() {
Expand Down

0 comments on commit b0a5a09

Please sign in to comment.