From ead6f96513c20e9b24bec809a6f0fa338154434c Mon Sep 17 00:00:00 2001 From: Jack Twilley Date: Fri, 20 Feb 2015 11:29:28 -0800 Subject: [PATCH 1/2] Changed MX check to respect priorities other than 10. Reordered the if a little, added some string parsing, and modified the OK text to include a warning. --- management/status_checks.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/management/status_checks.py b/management/status_checks.py index 23c9700d..28780515 100755 --- a/management/status_checks.py +++ b/management/status_checks.py @@ -417,12 +417,9 @@ def check_mail_domain(domain, env, output): # Check the MX record. mx = query_dns(domain, "MX", nxdomain=None) - expected_mx = "10 " + env['PRIMARY_HOSTNAME'] + recommended_mx = "10 " + env['PRIMARY_HOSTNAME'] - if mx == expected_mx: - output.print_ok("Domain's email is directed to this domain. [%s => %s]" % (domain, mx)) - - elif mx == None: + if mx == None: # A missing MX record is okay on the primary hostname because # the primary hostname's A record (the MX fallback) is... itself, # which is what we want the MX to be. @@ -440,12 +437,17 @@ def check_mail_domain(domain, env, output): else: output.print_error("""This domain's DNS MX record is not set. It should be '%s'. Mail will not be delivered to this box. It may take several hours for public DNS to update after a - change. This problem may result from other issues listed here.""" % (expected_mx,)) + change. This problem may result from other issues listed here.""" % (recommended_mx,)) - else: + elif mx.split(' ')[1] == recommended_mx.split(' ')[1]: + good_news = "Domain's email is directed to this domain. [%s => %s]" % (domain, mx) + if mx != recommended_mx: + good_news += " However, the usage of a non-standard priority value ('%s') is not recommended." % mx.split(' ')[0] + output.print_ok(good_news) + else: output.print_error("""This domain's DNS MX record is incorrect. It is currently set to '%s' but should be '%s'. Mail will not be delivered to this box. It may take several hours for public DNS to update after a change. This problem may result from - other issues listed here.""" % (mx, expected_mx)) + other issues listed here.""" % (mx, recommended_mx)) # Check that the postmaster@ email address exists. Not required if the domain has a # catch-all address or domain alias. From b2fcd4c9e51f7b795eb8b791c0cb696ca1dff2c0 Mon Sep 17 00:00:00 2001 From: Jack Twilley Date: Sun, 22 Feb 2015 17:05:09 -0800 Subject: [PATCH 2/2] Now supports domains with multiple MX records. The status check on MX records now correctly handles domains with multiple MX records. --- management/status_checks.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/management/status_checks.py b/management/status_checks.py index 28780515..70bdd412 100755 --- a/management/status_checks.py +++ b/management/status_checks.py @@ -416,10 +416,17 @@ def check_dnssec(domain, env, output, dns_zonefiles, is_checking_primary=False): def check_mail_domain(domain, env, output): # Check the MX record. - mx = query_dns(domain, "MX", nxdomain=None) recommended_mx = "10 " + env['PRIMARY_HOSTNAME'] + mx = query_dns(domain, "MX", nxdomain=None) - if mx == None: + if mx is None: + mxhost = None + else: + # query_dns returns a semicolon-delimited list + # of priority-host pairs. + mxhost = mx.split('; ')[0].split(' ')[1] + + if mxhost == None: # A missing MX record is okay on the primary hostname because # the primary hostname's A record (the MX fallback) is... itself, # which is what we want the MX to be. @@ -439,12 +446,12 @@ def check_mail_domain(domain, env, output): be delivered to this box. It may take several hours for public DNS to update after a change. This problem may result from other issues listed here.""" % (recommended_mx,)) - elif mx.split(' ')[1] == recommended_mx.split(' ')[1]: - good_news = "Domain's email is directed to this domain. [%s => %s]" % (domain, mx) - if mx != recommended_mx: - good_news += " However, the usage of a non-standard priority value ('%s') is not recommended." % mx.split(' ')[0] - output.print_ok(good_news) - else: + elif mxhost == env['PRIMARY_HOSTNAME']: + good_news = "Domain's email is directed to this domain. [%s => %s]" % (domain, mx) + if mx != recommended_mx: + good_news += " This configuration is non-standard. The recommended configuration is '%s'." % (recommended_mx,) + output.print_ok(good_news) + else: output.print_error("""This domain's DNS MX record is incorrect. It is currently set to '%s' but should be '%s'. Mail will not be delivered to this box. It may take several hours for public DNS to update after a change. This problem may result from other issues listed here.""" % (mx, recommended_mx))