diff --git a/data/hooks/diagnosis/24-mail.py b/data/hooks/diagnosis/24-mail.py
index 333d98c8a..f4f897e28 100644
--- a/data/hooks/diagnosis/24-mail.py
+++ b/data/hooks/diagnosis/24-mail.py
@@ -36,12 +36,13 @@ class MailDiagnoser(Diagnoser):
# Are IPs listed on a DNSBL ?
self.logger_debug("Running DNSBL detection")
- blacklisted_details = self.check_ip_dnsbl()
+ blacklisted_details = list(self.check_dnsbl(self.get_public_ips()))
+ print(blacklisted_details)
if blacklisted_details:
yield dict(meta={"test": "mail_blacklist"},
status="ERROR",
summary="diagnosis_mail_blacklist_nok",
- details=list(blacklisted_details))
+ details=blacklisted_details)
else:
yield dict(meta={"test": "mail_blacklist"},
status="SUCCESS",
@@ -57,23 +58,22 @@ class MailDiagnoser(Diagnoser):
# check for unusual failed sending attempt being refused in the logs ?
- def check_blacklisted(self):
+ def check_dnsbl(self, ips):
""" Check with dig onto blacklist DNS server
"""
dns_blacklists = read_yaml(DEFAULT_DNS_BLACKLIST)
- for ip in self.get_public_ips():
+ for ip in ips:
for blacklist in dns_blacklists:
-
- if "." in ip and not blacklist.ipv4:
+ if "." in ip and not blacklist['ipv4']:
continue
- if ":" in ip and not blacklist.ipv6:
+ if ":" in ip and not blacklist['ipv6']:
continue
# Determine if we are listed on this RBL
try:
rev = dns.reversename.from_address(ip)
- query = str(rev.split(3)[0]) + '.' + blacklist.dns_server
+ query = str(rev.split(3)[0]) + '.' + blacklist['dns_server']
# TODO add timeout lifetime
dns.resolver.query(query, "A")
except (dns.resolver.NXDOMAIN, dns.resolver.NoNameservers, dns.resolver.NoAnswer,
@@ -89,7 +89,8 @@ class MailDiagnoser(Diagnoser):
yield ('diagnosis_mail_blacklisted_by', {
'ip': ip,
- 'blacklist': blacklist,
+ 'blacklist_name': blacklist['name'],
+ 'blacklist_website': blacklist['website'],
'reason': reason})
def get_public_ips(self):
diff --git a/locales/en.json b/locales/en.json
index 37ae2a34f..93f7680bf 100644
--- a/locales/en.json
+++ b/locales/en.json
@@ -188,7 +188,7 @@
"diagnosis_mail_ougoing_port_25_blocked": "Outgoing port 25 appears to be blocked. You should try to unblock it in your internet service provider (or hosting provider) configuration panel. Meanwhile, the server won't be able to send emails to other servers.",
"diagnosis_mail_blacklist_ok": "Your server public IP are not listed on email blacklists.",
"diagnosis_mail_blacklist_nok": "Your server public IPs are listed on email blacklists.",
- "diagnosis_mail_blacklisted_by": "{ip} is listed on {blacklist.name}. Reason: {reason}. See {blacklist.website}",
+ "diagnosis_mail_blacklisted_by": "{ip} is listed on {blacklist_name}. Reason: {reason}. See {blacklist_website}",
"diagnosis_regenconf_allgood": "All configurations files are in line with the recommended configuration!",
"diagnosis_regenconf_manually_modified": "Configuration file {file}
appears to have been manually modified.",
"diagnosis_regenconf_manually_modified_details": "This is probably OK if you know what you're doing! YunoHost will stop updating this file automatically... But beware that YunoHost upgrades could contain important recommended changes. If you want to, you can inspect the differences with yunohost tools regen-conf {category} --dry-run --with-diff and force the reset to the recommended configuration with yunohost tools regen-conf {category} --force",