From a3ef53574c1baa7f04e4275f4a9c48dff62c1a56 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Wed, 25 Mar 2020 09:53:28 -0400 Subject: [PATCH] Support RFC 7505 "null MX" (#702) (#703) * Fix #702: Spurious null MX changes on CloudFlare * Test roundtripping null MX on Cloudflare * Use an if instead of TrimSuffix * Add other providers that support RFC 7505 * Suppress test for non-compliant providers --- integrationTest/integration_test.go | 5 +++++ providers/cloudflare/cloudflareProvider.go | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/integrationTest/integration_test.go b/integrationTest/integration_test.go index f921e6af1..b25a49a27 100644 --- a/integrationTest/integration_test.go +++ b/integrationTest/integration_test.go @@ -609,6 +609,11 @@ func makeTests(t *testing.T) []*TestGroup { tc("Record pointing to @", mx("foo", 8, "**current-domain**")), ), + testgroup("Null MX", + not("AZURE_DNS", "GANDI_V5", "NAMEDOTCOM", "DIGITALOCEAN"), // These providers don't support RFC 7505 + tc("Null MX", mx("@", 0, ".")), + ), + testgroup("NS", not("DNSIMPLE", "EXOSCALE"), // DNSIMPLE: Does not support NS records nor subdomains. diff --git a/providers/cloudflare/cloudflareProvider.go b/providers/cloudflare/cloudflareProvider.go index 0dc82f482..3f42de170 100644 --- a/providers/cloudflare/cloudflareProvider.go +++ b/providers/cloudflare/cloudflareProvider.go @@ -541,7 +541,9 @@ type cfRecord struct { func (c *cfRecord) nativeToRecord(domain string) *models.RecordConfig { // normalize cname,mx,ns records with dots to be consistent with our config format. if c.Type == "CNAME" || c.Type == "MX" || c.Type == "NS" || c.Type == "SRV" { - c.Content = dnsutil.AddOrigin(c.Content+".", domain) + if c.Content != "." { + c.Content = c.Content + "." + } } rc := &models.RecordConfig{