mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-09-29 00:14:37 +08:00
NETLIFY: fix SRV priority and allow apex NS records (#2549)
Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
This commit is contained in:
parent
a1c7a26351
commit
c4d5d9bf20
2 changed files with 1 additions and 37 deletions
|
@ -48,7 +48,7 @@ type dnsRecordCreate struct {
|
|||
Flag int64 `json:"flag"`
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
Port int64 `json:"port,omitempty"`
|
||||
Priority int64 `json:"priority,omitempty"`
|
||||
Priority int64 `json:"priority"`
|
||||
Tag string `json:"tag,omitempty"`
|
||||
TTL int64 `json:"ttl,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"github.com/StackExchange/dnscontrol/v4/models"
|
||||
"github.com/StackExchange/dnscontrol/v4/pkg/diff"
|
||||
"github.com/StackExchange/dnscontrol/v4/pkg/diff2"
|
||||
"github.com/StackExchange/dnscontrol/v4/pkg/printer"
|
||||
"github.com/StackExchange/dnscontrol/v4/providers"
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
@ -144,43 +143,8 @@ func (n *netlifyProvider) GetZoneRecords(domain string, meta map[string]string)
|
|||
return cleanRecords, nil
|
||||
}
|
||||
|
||||
// Return true if the string ends in one of Netlify's name server domains
|
||||
// False if anything else
|
||||
func isNetlifyNameServerDomain(name string) bool {
|
||||
for _, i := range nameServerSuffixes {
|
||||
if strings.HasSuffix(name, i) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// remove all non-netlify NS records from our desired state.
|
||||
// if any are found, print a warning
|
||||
func removeOtherApexNS(dc *models.DomainConfig) {
|
||||
newList := make([]*models.RecordConfig, 0, len(dc.Records))
|
||||
for _, rec := range dc.Records {
|
||||
if rec.Type == "NS" {
|
||||
// apex NS inside netlify are expected.
|
||||
// We ignore them, warning as needed.
|
||||
// Child delegations are supported so, we allow non-apex NS records.
|
||||
if rec.GetLabelFQDN() == dc.Name {
|
||||
if !isNetlifyNameServerDomain(rec.GetTargetField()) {
|
||||
printer.Printf("Warning: Netlify does not allow NS records to be modified. %s will not be added.\n", rec.GetTargetField())
|
||||
}
|
||||
continue
|
||||
}
|
||||
}
|
||||
newList = append(newList, rec)
|
||||
}
|
||||
dc.Records = newList
|
||||
}
|
||||
|
||||
// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
|
||||
func (n *netlifyProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, records models.Records) ([]*models.Correction, error) {
|
||||
|
||||
removeOtherApexNS(dc)
|
||||
|
||||
var corrections []*models.Correction
|
||||
var differ diff.Differ
|
||||
if !diff2.EnableDiff2 {
|
||||
|
|
Loading…
Add table
Reference in a new issue