Skip to content

Commit 979b32b

Browse files
committed
Ref #670 - Change MX result caching to IP-based
1 parent a7f8fc4 commit 979b32b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

checks/tasks/tls.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
# SPDX-License-Identifier: Apache-2.0
33
import errno
44
import http.client
5+
import itertools
56
import socket
67
import ssl
78
import time
89

10+
import unbound
911
from binascii import hexlify
1012
from enum import Enum
1113
from itertools import product
@@ -1755,10 +1757,15 @@ def do_mail_smtp_starttls(mailservers, url, task, *args, **kwargs):
17551757
cache_ttl = redis_id.mail_starttls.ttl
17561758
while timer() - start < cache_ttl and not all(results.values()) > 0:
17571759
for server, dane_cb_data, _ in mailservers:
1760+
cache_key = ";".join(
1761+
itertools.chain.from_iterable(
1762+
[sorted(task.resolve(server, rr_type)) for rr_type in [unbound.RR_TYPE_A, unbound.RR_TYPE_AAAA]]
1763+
)
1764+
)
17581765
if results[server]:
17591766
continue
17601767
# Check if we already have cached results.
1761-
cache_id = redis_id.mail_starttls.id.format(server)
1768+
cache_id = redis_id.mail_starttls.id.format(cache_key)
17621769
if cache.add(cache_id, False, cache_ttl):
17631770
# We do not have cached results, get them and cache them.
17641771
results[server] = check_mail_tls(server, dane_cb_data, task)

0 commit comments

Comments
 (0)