mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
@ -2,6 +2,7 @@ package namecheap
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/StackExchange/dnscontrol/models"
|
"github.com/StackExchange/dnscontrol/models"
|
||||||
@ -34,20 +35,20 @@ func (n *Namecheap) GetRegistrarCorrections(dc *models.DomainConfig) ([]*models.
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
//todo: sort both
|
sort.Strings(info.DNSDetails.Nameservers)
|
||||||
found := strings.Join(info.DNSDetails.Nameservers, ",")
|
found := strings.Join(info.DNSDetails.Nameservers, ",")
|
||||||
desired := ""
|
desiredNs := []string{}
|
||||||
for _, d := range dc.Nameservers {
|
for _, d := range dc.Nameservers {
|
||||||
if desired != "" {
|
desiredNs = append(desiredNs, d.Name)
|
||||||
desired += ","
|
|
||||||
}
|
|
||||||
desired += d.Name
|
|
||||||
}
|
}
|
||||||
|
sort.Strings(desiredNs)
|
||||||
|
desired := strings.Join(desiredNs, ",")
|
||||||
if found != desired {
|
if found != desired {
|
||||||
parts := strings.SplitN(dc.Name, ".", 2)
|
parts := strings.SplitN(dc.Name, ".", 2)
|
||||||
sld, tld := parts[0], parts[1]
|
sld, tld := parts[0], parts[1]
|
||||||
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'", found, desired),
|
||||||
F: func() error {
|
F: func() error {
|
||||||
_, err := n.client.DomainDNSSetCustom(sld, tld, desired)
|
_, err := n.client.DomainDNSSetCustom(sld, tld, desired)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user