mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-01-13 19:07:57 +08:00
752e25471d
* Move the registrar features to a separate file * Prepare the testing framework * Roughed out functions * Fix up structs * WIP! * First tests pass * wip! * Flesh out remaining rTypes, get nameservers, etc * Fix TXT records * Clean up code * More cleanups. Fix CAA/SRV * Linting * Cleanups/linting * Fix CAA [more] and more cleanups * CSC does not like very long txt records * Use timer only when interactive * Disable CAA for now * Update docs * Remove debug printf * add go-isatty * cleanups
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package cscglobal
|
|
|
|
import (
|
|
"fmt"
|
|
"sort"
|
|
"strings"
|
|
|
|
"github.com/StackExchange/dnscontrol/v3/models"
|
|
)
|
|
|
|
// GetRegistrarCorrections gathers corrections that would being n to match dc.
|
|
func (client *providerClient) GetRegistrarCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
|
|
nss, err := client.getNameservers(dc.Name)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
foundNameservers := strings.Join(nss, ",")
|
|
|
|
expected := []string{}
|
|
for _, ns := range dc.Nameservers {
|
|
if ns.Name[len(ns.Name)-1] == '.' {
|
|
// When this code was written ns.Name never included a single trailing dot.
|
|
// If that changes, the code should change too.
|
|
return nil, fmt.Errorf("name server includes a trailing dot, has the API changed?")
|
|
}
|
|
expected = append(expected, ns.Name)
|
|
}
|
|
sort.Strings(expected)
|
|
expectedNameservers := strings.Join(expected, ",")
|
|
|
|
if foundNameservers != expectedNameservers {
|
|
return []*models.Correction{
|
|
{
|
|
Msg: fmt.Sprintf("Update nameservers %s -> %s", foundNameservers, expectedNameservers),
|
|
F: func() error {
|
|
return client.updateNameservers(expected, dc.Name)
|
|
},
|
|
},
|
|
}, nil
|
|
}
|
|
return nil, nil
|
|
}
|