mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Nameserver overhaul (#17)
* go changes to support nameservers_from * clear nameservers before giving to dsp. * work * work * nameserver updates. * remove unused * name.com stinks at NS records. * whitespace * removing web(belongs in own repo). First sketch of DSP vs NAMESERVER_FROM * add DEFAULTS to replace defaultDsps. * initial gcloud provider. Simple records work. * namedotcom can do subdomain ns records now. * fix for mx and txt * kill dsp acronym
This commit is contained in:
@@ -8,11 +8,11 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/miekg/dns/dnsutil"
|
||||
"github.com/StackExchange/dnscontrol/models"
|
||||
"github.com/StackExchange/dnscontrol/providers"
|
||||
"github.com/StackExchange/dnscontrol/providers/diff"
|
||||
"github.com/StackExchange/dnscontrol/transform"
|
||||
"github.com/miekg/dns/dnsutil"
|
||||
)
|
||||
|
||||
/*
|
||||
@@ -38,7 +38,7 @@ type CloudflareApi struct {
|
||||
ApiKey string `json:"apikey"`
|
||||
ApiUser string `json:"apiuser"`
|
||||
domainIndex map[string]string
|
||||
nameservers map[string][]*models.Nameserver
|
||||
nameservers map[string][]string
|
||||
ipConversions []transform.IpConversion
|
||||
secretIPs []net.IP
|
||||
ignoredLabels []string
|
||||
@@ -53,6 +53,18 @@ func labelMatches(label string, matches []string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
func (c *CloudflareApi) GetNameservers(domain string) ([]*models.Nameserver, error) {
|
||||
if c.domainIndex == nil {
|
||||
if err := c.fetchDomainList(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
ns, ok := c.nameservers[domain]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("Nameservers for %s not found in cloudflare account", domain)
|
||||
}
|
||||
return models.StringsToNameservers(ns), nil
|
||||
}
|
||||
|
||||
func (c *CloudflareApi) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
|
||||
if c.domainIndex == nil {
|
||||
@@ -64,8 +76,6 @@ func (c *CloudflareApi) GetDomainCorrections(dc *models.DomainConfig) ([]*models
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("%s not listed in zones for cloudflare account", dc.Name)
|
||||
}
|
||||
|
||||
dc.Nameservers = c.nameservers[dc.Name]
|
||||
if err := c.preprocessConfig(dc); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -94,6 +104,12 @@ func (c *CloudflareApi) GetDomainCorrections(dc *models.DomainConfig) ([]*models
|
||||
log.Fatalf("FATAL: dnsconfig contains label that matches ignored_labels: %#v is in %v)\n", rec.Name, c.ignoredLabels)
|
||||
// Since we log.Fatalf, we don't need to be clean here.
|
||||
}
|
||||
if rec.Type == "NS" && rec.NameFQDN == dc.Name {
|
||||
if !strings.HasSuffix(rec.Target, ".ns.cloudflare.com.") {
|
||||
log.Printf("Warning: cloudflare does not support modifying NS records on base domain. %s will not be added.", rec.Target)
|
||||
}
|
||||
continue
|
||||
}
|
||||
expectedRecords = append(expectedRecords, recordWrapper{rec})
|
||||
}
|
||||
_, create, del, mod := diff.IncrementalDiff(records, expectedRecords)
|
||||
|
||||
@@ -20,7 +20,7 @@ const (
|
||||
// get list of domains for account. Cache so the ids can be looked up from domain name
|
||||
func (c *CloudflareApi) fetchDomainList() error {
|
||||
c.domainIndex = map[string]string{}
|
||||
c.nameservers = map[string][]*models.Nameserver{}
|
||||
c.nameservers = map[string][]string{}
|
||||
page := 1
|
||||
for {
|
||||
zr := &zoneResponse{}
|
||||
@@ -34,7 +34,7 @@ func (c *CloudflareApi) fetchDomainList() error {
|
||||
for _, zone := range zr.Result {
|
||||
c.domainIndex[zone.Name] = zone.ID
|
||||
for _, ns := range zone.Nameservers {
|
||||
c.nameservers[zone.Name] = append(c.nameservers[zone.Name], &models.Nameserver{Name: ns})
|
||||
c.nameservers[zone.Name] = append(c.nameservers[zone.Name], ns)
|
||||
}
|
||||
}
|
||||
ri := zr.ResultInfo
|
||||
|
||||
Reference in New Issue
Block a user