More generic dnsbl validation

This commit is contained in:
Spitap
2022-09-05 11:07:26 +02:00
parent ed9e12d2f7
commit e662fd943d
@@ -79,8 +79,10 @@ class CheckMXRecords(BaseCommand):
pattern = "{}.{}.".format(reverse, provider)
try:
result = socket.gethostbyname(pattern)
#Mitigate Spamhaus status error (these codes don't mean ip is listed)
if result == "127.255.255.254" or result == "127.255.255.255":
#result from dnsbl is in ipv4 format
splited_result = result.split(".")
if int(splited_result[-1]) <= 15:
#Typical dnsbl result : 127.255.255.[1-15] (depends on services)
result = False
except socket.gaierror:
result = False