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

OVH: Fixed registrar ns correction (#486)

This commit is contained in:
Patrik Kernstock
2019-05-23 15:25:26 +02:00
committed by Tom Limoncelli
parent f9df8c744a
commit 7ed3adb2f1
2 changed files with 19 additions and 14 deletions

View File

@@ -64,7 +64,7 @@ func (c *ovhProvider) GetNameservers(domain string) ([]*models.Nameserver, error
return nil, errors.Errorf("%s not listed in zones for ovh account", domain) return nil, errors.Errorf("%s not listed in zones for ovh account", domain)
} }
ns, err := c.fetchNS(domain) ns, err := c.fetchRegistrarNS(domain)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -177,27 +177,31 @@ func nativeToRecord(r *Record, origin string) *models.RecordConfig {
func (c *ovhProvider) GetRegistrarCorrections(dc *models.DomainConfig) ([]*models.Correction, error) { func (c *ovhProvider) GetRegistrarCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
ns, err := c.fetchRegistrarNS(dc.Name) // get the actual in-use nameservers
actualNs, err := c.fetchRegistrarNS(dc.Name)
if err != nil { if err != nil {
return nil, err return nil, err
} }
sort.Strings(ns) // get the actual used ones + the configured one through dnscontrol
found := strings.Join(ns, ",") expectedNs := []string{}
desiredNs := []string{}
for _, d := range dc.Nameservers { for _, d := range dc.Nameservers {
desiredNs = append(desiredNs, d.Name) expectedNs = append(expectedNs, d.Name)
} }
sort.Strings(desiredNs)
desired := strings.Join(desiredNs, ",")
if found != desired { sort.Strings(actualNs)
actual := strings.Join(actualNs, ",")
sort.Strings(expectedNs)
expected := strings.Join(expectedNs, ",")
// check if we need to change something
if actual != expected {
return []*models.Correction{ return []*models.Correction{
{ {
Msg: fmt.Sprintf("Change Nameservers from '%s' to '%s'", found, desired), Msg: fmt.Sprintf("Change Nameservers from '%s' to '%s'", actual, expected),
F: func() error { F: func() error {
err := c.updateNS(dc.Name, desiredNs) err := c.updateNS(dc.Name, expectedNs)
if err != nil { if err != nil {
return err return err
} }
@@ -205,5 +209,6 @@ func (c *ovhProvider) GetRegistrarCorrections(dc *models.DomainConfig) ([]*model
}}, }},
}, nil }, nil
} }
return nil, nil return nil, nil
} }

View File

@@ -36,10 +36,10 @@ func (c *ovhProvider) fetchZones() error {
// Zone describes the attributes of a DNS zone. // Zone describes the attributes of a DNS zone.
type Zone struct { type Zone struct {
LastUpdate string `json:"lastUpdate,omitempty"` DNSSecSupported bool `json:"dnssecSupported"`
HasDNSAnycast bool `json:"hasDNSAnycast,omitempty"` HasDNSAnycast bool `json:"hasDNSAnycast,omitempty"`
NameServers []string `json:"nameServers"` NameServers []string `json:"nameServers"`
DNSSecSupported bool `json:"dnssecSupported"` LastUpdate string `json:"lastUpdate,omitempty"`
} }
// get info about a zone. // get info about a zone.