1
0
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:
Craig Peterson
2016-12-16 13:10:27 -07:00
committed by GitHub
parent 9cb81da20e
commit 1ea80d5347
50 changed files with 672 additions and 66342 deletions

View File

@@ -49,8 +49,9 @@ func (s SoaInfo) String() string {
}
type Bind struct {
Default_ns []string `json:"default_ns"`
Default_Soa SoaInfo `json:"default_soa"`
Default_NS []string `json:"default_ns"`
Default_Soa SoaInfo `json:"default_soa"`
nameservers []*models.Nameserver `json:"-"`
}
var bindBaseDir = flag.String("bindtree", "zones", "BIND: Directory that stores BIND zonefiles.")
@@ -138,18 +139,8 @@ func makeDefaultSOA(info SoaInfo, origin string) *models.RecordConfig {
return &soa_rec
}
func makeDefaultNS(origin string, names []string) []*models.RecordConfig {
var result []*models.RecordConfig
for _, n := range names {
rc := &models.RecordConfig{
Type: "NS",
Name: "@",
Target: n,
}
rc.NameFQDN = dnsutil.AddOrigin(rc.Name, origin)
result = append(result, rc)
}
return result
func (c *Bind) GetNameservers(string) ([]*models.Nameserver, error) {
return c.nameservers, nil
}
func (c *Bind) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
@@ -207,11 +198,6 @@ func (c *Bind) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correcti
}
}
// Add NS records:
if len(c.Default_ns) != 0 && !dc.HasRecordTypeName("NS", "@") {
expectedRecords = append(expectedRecords, makeDefaultNS(dc.Name, c.Default_ns)...)
dc.Records = append(dc.Records, makeDefaultNS(dc.Name, c.Default_ns)...)
}
// Add SOA record:
if !dc.HasRecordTypeName("SOA", "@") {
expectedRecords = append(expectedRecords, soa_rec)
@@ -286,7 +272,7 @@ func (c *Bind) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correcti
}
func initBind(config map[string]string, providermeta json.RawMessage) (providers.DNSServiceProvider, error) {
// m -- the json blob from creds.json
// config -- the key/values from creds.json
// meta -- the json blob from NewReq('name', 'TYPE', meta)
api := &Bind{}
@@ -296,6 +282,7 @@ func initBind(config map[string]string, providermeta json.RawMessage) (providers
return nil, err
}
}
api.nameservers = models.StringsToNameservers(api.Default_NS)
return api, nil
}

View File

@@ -115,21 +115,20 @@ func TestWriteZoneFileOrder(t *testing.T) {
r, _ := dns.NewRR(fmt.Sprintf("%s 300 IN A 1.2.3.%d", name, i))
records = append(records, r)
}
records[0].Header().Name = "stackoverflow.com."
records[1].Header().Name = "@"
buf := &bytes.Buffer{}
WriteZoneFile(buf, records, "stackoverflow.com.", 300)
// Compare
if buf.String() != testdataOrder {
t.Log("Found:")
t.Log(buf.String())
t.Log("Expected:")
t.Log(testdataOrder)
t.Fatalf("Zone file does not match.")
}
parseAndRegen(t, buf, testdataOrder)
// Now shuffle the list many times and make sure it still works:
for iteration := 5; iteration > 0; iteration-- {
// Randomize the list:
perm := rand.Perm(len(records))