Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GANDI: Add support for CAA rtype #288

Merged
merged 2 commits into from
Dec 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/_includes/matrix.html
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@
<td class="success">
<i class="fa fa-check text-success" aria-hidden="true"></i>
</td>
<td><i class="fa fa-minus dim"></i></td>
<td class="success">
<i class="fa fa-check text-success" aria-hidden="true"></i>
</td>
<td class="success">
<i class="fa fa-check text-success" aria-hidden="true"></i>
</td>
Expand Down
16 changes: 16 additions & 0 deletions models/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,22 @@ func SplitCombinedSrvValue(s string) (priority, weight, port uint16, target stri
return uint16(priorityconv), uint16(weightconv), uint16(portconv), parts[3], nil
}

// CombineCAAs will merge the tags and flags into the target field for all CAA records.
// Useful for providers that desire them as one field.
func (dc *DomainConfig) CombineCAAs() {
for _, rec := range dc.Records {
if rec.Type == "CAA" {
if rec.CombinedTarget {
pm := strings.Join([]string{"CombineCAAs: Already collapsed: ", rec.Name, rec.Target}, " ")
panic(pm)
}
rec.Target = rec.Content()
fmt.Printf("DEBUG: NEW TARGET: %v\n", rec.Target)
rec.CombinedTarget = true
}
}
}

func SplitCombinedCaaValue(s string) (tag string, flag uint8, value string, err error) {

splitData := strings.SplitN(s, " ", 3)
Expand Down
10 changes: 8 additions & 2 deletions providers/gandi/gandiProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ var docNotes = providers.DocumentationNotes{
}

func init() {
providers.RegisterDomainServiceProviderType("GANDI", newDsp, providers.CanUsePTR,
providers.CanUseSRV, docNotes, providers.CantUseNOPURGE)
providers.RegisterDomainServiceProviderType("GANDI", newDsp,
providers.CanUseCAA,
providers.CanUsePTR,
providers.CanUseSRV,
providers.CantUseNOPURGE,
docNotes,
)
providers.RegisterRegistrarType("GANDI", newReg)
}

Expand Down Expand Up @@ -74,6 +79,7 @@ func (c *GandiApi) GetNameservers(domain string) ([]*models.Nameserver, error) {
func (c *GandiApi) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
dc.Punycode()
dc.CombineSRVs()
dc.CombineCAAs()
dc.CombineMXs()
domaininfo, err := c.getDomainInfo(dc.Name)
if err != nil {
Expand Down
8 changes: 7 additions & 1 deletion providers/gandi/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,19 @@ func convert(r *gandirecord.RecordInfo, origin string) *models.RecordConfig {
}
switch r.Type {
case "A", "AAAA", "NS", "CNAME", "PTR", "TXT":
// no-op
case "CAA":
var err error
rc.CaaTag, rc.CaaFlag, rc.Target, err = models.SplitCombinedCaaValue(r.Value)
if err != nil {
panic(fmt.Sprintf("gandi.convert bad caa value format: %#v (%s)", r.Value, err))
}
case "SRV":
var err error
rc.SrvPriority, rc.SrvWeight, rc.SrvPort, rc.Target, err = models.SplitCombinedSrvValue(r.Value)
if err != nil {
panic(fmt.Sprintf("gandi.convert bad srv value format: %#v (%s)", r.Value, err))
}
// no-op
case "MX":
var err error
rc.MxPreference, rc.Target, err = models.SplitCombinedMxValue(r.Value)
Expand Down