1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

CLOUDFLARE: Support CAA rtype (#285)

* Add CAA support to cloudflare
This commit is contained in:
Tom Limoncelli
2017-12-20 10:25:23 -05:00
committed by GitHub
parent ed2b34d473
commit 611a597ae0
5 changed files with 95 additions and 14 deletions

View File

@@ -60,6 +60,18 @@ type DNSProviderConfig struct {
// NameFQDN:
// This is the FQDN version of Name.
// It should never have a trailiing ".".
// Valid types:
// A
// AAAA
// ANAME
// CAA
// CNAME
// MX
// NS
// SRV
// TXT
// PAGE_RULE // pseudo rtype
// TODO(tal): Add all the pseudo types
type RecordConfig struct {
Type string `json:"type"`
Name string `json:"name"` // The short name. See below.
@@ -418,6 +430,32 @@ func SplitCombinedSrvValue(s string) (priority, weight, port uint16, target stri
return uint16(priorityconv), uint16(weightconv), uint16(portconv), parts[3], nil
}
func SplitCombinedCaaValue(s string) (tag string, flag uint8, value string, err error) {
splitData := strings.SplitN(s, " ", 3)
if len(splitData) != 3 {
err = fmt.Errorf("Unexpected data for CAA record returned by Vultr")
return
}
lflag, err := strconv.ParseUint(splitData[0], 10, 8)
if err != nil {
return
}
flag = uint8(lflag)
tag = splitData[1]
value = splitData[2]
if strings.HasPrefix(value, `"`) && strings.HasSuffix(value, `"`) {
value = value[1 : len(value)-1]
}
if strings.HasPrefix(value, `'`) && strings.HasSuffix(value, `'`) {
value = value[1 : len(value)-1]
}
return
}
func copyObj(input interface{}, output interface{}) error {
buf := &bytes.Buffer{}
enc := gob.NewEncoder(buf)