mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
BIND: Implement get-zones (#642)
* BIND: implement get-zones * BIND: Implement ZoneLister
This commit is contained in:
@ -38,11 +38,10 @@ var supportedTypes = map[string]bool{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetZoneRecords gets the records of a zone and returns them in RecordConfig format.
|
// GetZoneRecords gets the records of a zone and returns them in RecordConfig format.
|
||||||
func (client *adProvider) GetZoneRecords(domain string) (models.Records, error) {
|
func (c *adProvider) GetZoneRecords(domain string) (models.Records, error) {
|
||||||
// Read foundRecords:
|
foundRecords, err := c.getExistingRecords(domain)
|
||||||
foundRecords, err := c.getExistingRecords(dc.Name)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("c.getExistingRecords(%q) failed: %v", dc.Name, err)
|
return nil, fmt.Errorf("c.getExistingRecords(%q) failed: %v", domain, err)
|
||||||
}
|
}
|
||||||
return foundRecords, nil
|
return foundRecords, nil
|
||||||
}
|
}
|
||||||
|
@ -130,10 +130,28 @@ func (c *Bind) GetNameservers(string) ([]*models.Nameserver, error) {
|
|||||||
return c.nameservers, nil
|
return c.nameservers, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListZones returns all the zones in an account
|
||||||
|
func (c *Bind) ListZones() ([]string, error) {
|
||||||
|
if _, err := os.Stat(c.directory); os.IsNotExist(err) {
|
||||||
|
return nil, fmt.Errorf("BIND directory %q does not exist!\n", c.directory)
|
||||||
|
}
|
||||||
|
|
||||||
|
filenames, err := filepath.Glob(filepath.Join(c.directory, "*.zone"))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var zones []string
|
||||||
|
for _, n := range filenames {
|
||||||
|
_, file := filepath.Split(n)
|
||||||
|
zones = append(zones, strings.TrimSuffix(file, ".zone"))
|
||||||
|
}
|
||||||
|
return zones, nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetZoneRecords gets the records of a zone and returns them in RecordConfig format.
|
// GetZoneRecords gets the records of a zone and returns them in RecordConfig format.
|
||||||
func (c *Bind) GetZoneRecords(domain string) (models.Records, error) {
|
func (c *Bind) GetZoneRecords(domain string) (models.Records, error) {
|
||||||
// Default SOA record. If we see one in the zone, this will be replaced.
|
|
||||||
|
|
||||||
|
// Default SOA record. If we see one in the zone, this will be replaced.
|
||||||
soaRec := makeDefaultSOA(c.DefaultSoa, domain)
|
soaRec := makeDefaultSOA(c.DefaultSoa, domain)
|
||||||
foundRecords := models.Records{}
|
foundRecords := models.Records{}
|
||||||
var oldSerial, newSerial uint32
|
var oldSerial, newSerial uint32
|
||||||
|
Reference in New Issue
Block a user