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

BUG: Some DNS zones are downloaded twice (#2120)

Signed-off-by: Amelia Aronsohn <squirrel@wearing.black>
Co-authored-by: Tom Limoncelli <tal@whatexit.org>
Co-authored-by: Grégoire Henry <hnrgrgr@users.noreply.github.com>
Co-authored-by: Amelia Aronsohn <squirrel@wearing.black>
Co-authored-by: Kai Schwarz <kschwarz@hexonet.net>
Co-authored-by: Asif Nawaz <asif.nawaz@centralnic.com>
Co-authored-by: imlonghao <git@imlonghao.com>
Co-authored-by: Will Power <1619102+willpower232@users.noreply.github.com>
This commit is contained in:
Tom Limoncelli
2023-04-14 15:22:23 -04:00
committed by GitHub
parent 61559f6a96
commit 60470a3886
56 changed files with 994 additions and 1186 deletions

View File

@@ -74,28 +74,28 @@ func (c *desecProvider) GetNameservers(domain string) ([]*models.Nameserver, err
return models.ToNameservers(defaultNameServerNames)
}
func (c *desecProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
if dc.AutoDNSSEC == "off" {
printer.Printf("Notice: DNSSEC signing was not requested, but cannot be turned off. (deSEC always signs all records.)\n")
}
// func (c *desecProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
// if dc.AutoDNSSEC == "off" {
// printer.Printf("Notice: DNSSEC signing was not requested, but cannot be turned off. (deSEC always signs all records.)\n")
// }
existing, err := c.GetZoneRecords(dc.Name)
if err != nil {
return nil, err
}
models.PostProcessRecords(existing)
clean := PrepFoundRecords(existing)
var minTTL uint32
c.mutex.Lock()
if ttl, ok := c.domainIndex[dc.Name]; !ok {
minTTL = 3600
} else {
minTTL = ttl
}
c.mutex.Unlock()
PrepDesiredRecords(dc, minTTL)
return c.GenerateDomainCorrections(dc, clean)
}
// existing, err := c.GetZoneRecords(dc.Name)
// if err != nil {
// return nil, err
// }
// models.PostProcessRecords(existing)
// clean := PrepFoundRecords(existing)
// var minTTL uint32
// c.mutex.Lock()
// if ttl, ok := c.domainIndex[dc.Name]; !ok {
// minTTL = 3600
// } else {
// minTTL = ttl
// }
// c.mutex.Unlock()
// PrepDesiredRecords(dc, minTTL)
// return c.GetZoneRecordsCorrections(dc, clean)
// }
// GetZoneRecords gets the records of a zone and returns them in RecordConfig format.
func (c *desecProvider) GetZoneRecords(domain string) (models.Records, error) {
@@ -110,6 +110,7 @@ func (c *desecProvider) GetZoneRecords(domain string) (models.Records, error) {
for _, rr := range records {
existingRecords = append(existingRecords, nativeToRecords(rr, domain)...)
}
return existingRecords, nil
}
@@ -123,14 +124,6 @@ func (c *desecProvider) EnsureZoneExists(domain string) error {
return c.createDomain(domain)
}
// PrepFoundRecords munges any records to make them compatible with
// this provider. Usually this is a no-op.
func PrepFoundRecords(recs models.Records) models.Records {
// If there are records that need to be modified, removed, etc. we
// do it here. Usually this is a no-op.
return recs
}
// PrepDesiredRecords munges any records to best suit this provider.
func PrepDesiredRecords(dc *models.DomainConfig, minTTL uint32) {
// Sort through the dc.Records, eliminate any that can't be
@@ -138,8 +131,7 @@ func PrepDesiredRecords(dc *models.DomainConfig, minTTL uint32) {
// provider. We try to do minimal changes otherwise it gets
// confusing.
dc.Punycode()
txtutil.SplitSingleLongTxt(dc.Records)
//dc.Punycode()
recordsToKeep := make([]*models.RecordConfig, 0, len(dc.Records))
for _, rec := range dc.Records {
if rec.Type == "ALIAS" {
@@ -158,12 +150,19 @@ func PrepDesiredRecords(dc *models.DomainConfig, minTTL uint32) {
dc.Records = recordsToKeep
}
// GenerateDomainCorrections takes the desired and existing records
// and produces a Correction list. The correction list is simply
// a list of functions to call to actually make the desired
// correction, and a message to output to the user when the change is
// made.
func (c *desecProvider) GenerateDomainCorrections(dc *models.DomainConfig, existing models.Records) ([]*models.Correction, error) {
// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (c *desecProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existing models.Records) ([]*models.Correction, error) {
txtutil.SplitSingleLongTxt(dc.Records)
var minTTL uint32
c.mutex.Lock()
if ttl, ok := c.domainIndex[dc.Name]; !ok {
minTTL = 3600
} else {
minTTL = ttl
}
c.mutex.Unlock()
PrepDesiredRecords(dc, minTTL)
var corrections []*models.Correction
var err error