50 lines
1.3 KiB
Go
50 lines
1.3 KiB
Go
package pancheri
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
type Zone struct {
|
|
Root string `yaml:"root"`
|
|
ReducedHash string `yaml:"rsha"`
|
|
Zonefile string `yaml:"zf"`
|
|
ARecords map[string]RecordA `yaml:"ra"`
|
|
AAAARecords map[string]RecordAAAA `yaml:"rav6"`
|
|
CNAMERecords map[string]RecordCNAME `yaml:"rcn"`
|
|
TXTRecords map[string]RecordTXT `yaml:"rtx"`
|
|
}
|
|
|
|
func (z *Zone) RenderZone() string {
|
|
outString := ""
|
|
outString += fmt.Sprintf(";; Rendered zonefile for %s (rsha %s) at %s\n", z.Zonefile, z.ReducedHash, time.Now().Format(time.RFC3339))
|
|
outString += ";; Generated by pancheri-render. Note: this will NOT work out of the box!\n"
|
|
outString += ";; At the very least, you'll need add SOA and NS values.\n"
|
|
outString += "\n"
|
|
outString += ";; A Records\n"
|
|
|
|
for _, record := range z.ARecords {
|
|
outString += record.Render().String() + "\n"
|
|
}
|
|
|
|
outString += ";; AAAA Records\n"
|
|
|
|
for _, record := range z.AAAARecords {
|
|
outString += record.Render().String() + "\n"
|
|
}
|
|
|
|
outString += ";; CNAME Records\n"
|
|
|
|
for _, record := range z.CNAMERecords {
|
|
outString += record.Render().String() + "\n"
|
|
}
|
|
|
|
outString += ";; TXT Records\n"
|
|
|
|
for _, record := range z.TXTRecords {
|
|
outString += record.Render().String() + "\n"
|
|
}
|
|
|
|
return outString
|
|
}
|