CLOUDFLAREAPI: Support TXTMulti and empty TXT targets (#978)

* CLOUDFLAREAPI: Add TXTMulti support

* CLOUDFLAREAPI: Support TXTMulti and empty TXT strings
This commit is contained in:
Tom Limoncelli 2020-11-29 14:39:15 -05:00 committed by GitHub
parent 12a3354c0c
commit 096458d91c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View file

@ -698,7 +698,7 @@ func makeTests(t *testing.T) []*TestGroup {
),
testgroup("empty TXT",
not("CLOUDFLAREAPI", "HETZNER", "HEXONET", "INWX", "NETCUP"),
not("HETZNER", "HEXONET", "INWX", "NETCUP"),
tc("TXT with empty str", txt("foo1", "")),
// https://github.com/StackExchange/dnscontrol/issues/598
// We decided that permitting the TXT target to be an empty

View file

@ -45,6 +45,7 @@ var features = providers.DocumentationNotes{
providers.CanUseTLSA: providers.Can(),
providers.CanUseSSHFP: providers.Can(),
providers.CanUseDS: providers.Can(),
providers.CanUseTXTMulti: providers.Can(),
providers.DocCreateDomains: providers.Can(),
providers.DocDualHost: providers.Cannot("Cloudflare will not work well in situations where it is not the only DNS server"),
providers.DocOfficiallySupported: providers.Can(),

View file

@ -194,6 +194,11 @@ func (c *cloudflareProvider) createRec(rec *models.RecordConfig, domainID string
if rec.Type == "MX" {
prio = fmt.Sprintf(" %d ", rec.MxPreference)
}
if rec.Type == "TXT" {
if len(rec.TxtStrings) > 1 {
content = `"` + strings.Join(rec.TxtStrings, `" "`) + `"`
}
}
if rec.Type == "DS" {
content = fmt.Sprintf("%d %d %d %s", rec.DsKeyTag, rec.DsAlgorithm, rec.DsDigestType, rec.DsDigest)
}
@ -272,6 +277,11 @@ func (c *cloudflareProvider) modifyRecord(domainID, recID string, proxied bool,
TTL: rec.TTL,
Data: nil,
}
if rec.Type == "TXT" {
if len(rec.TxtStrings) > 1 {
r.Content = `"` + strings.Join(rec.TxtStrings, `" "`) + `"`
}
}
if rec.Type == "SRV" {
r.Data = cfSrvData(rec)
r.Name = rec.GetLabelFQDN()