Support multiple TXT entries for TLD

The dig of TXT for @ can returns multiple entries.
In that case, the DNS diagnosis fails.

The modification preserves the handling of DMARC and the likes
which use a single entry and a specfic domain name.

For single entry list, the behavior is preserved.

If mutliple TXT entries are defined for @, only the v=spf1
one is returned.

Signed-off-by: Nicolas Palix <nicolas.palix@imag.fr>
This commit is contained in:
Nicolas Palix 2023-06-20 15:20:51 +02:00
parent 19eb48b6e7
commit 460e39a2f0

View file

@ -182,6 +182,10 @@ class MyDiagnoser(Diagnoser):
if success != "ok":
return None
else:
if type_ == "TXT" and isinstance(answers,list):
for part in answers:
if part.startswith('"v=spf1'):
return part
return answers[0] if len(answers) == 1 else answers
def current_record_match_expected(self, r):