pancheri/zone.go

53 lines
1.3 KiB
Go
Raw Normal View History

2023-10-02 14:21:08 +00:00
package pancheri
import (
"fmt"
"time"
)
type Zone struct {
Root string `yaml:"root"`
ReducedHash string `yaml:"rsha"`
Zonefile string `yaml:"zf"`
ARecords []RecordA `yaml:"ra"`
AAAARecords []RecordAAAA `yaml:"rav6"`
CNAMERecords []RecordCNAME `yaml:"rcn"`
TXTRecords []RecordTXT `yaml:"rtx"`
2023-10-02 14:21:08 +00:00
}
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 to change the SOA and NS values.\n"
outString += "\n"
outString += ";; SOA & NS records\n"
outString += ";; TODO\n"
outString += "\n"
outString += ";; A Records\n"
for _, record := range z.ARecords {
2023-10-02 14:24:01 +00:00
outString += record.Render().String() + "\n"
2023-10-02 14:21:08 +00:00
}
outString += ";; AAAA Records\n"
for _, record := range z.AAAARecords {
2023-10-02 14:24:01 +00:00
outString += record.Render().String() + "\n"
2023-10-02 14:21:08 +00:00
}
outString += ";; CNAME Records\n"
for _, record := range z.CNAMERecords {
2023-10-02 14:24:01 +00:00
outString += record.Render().String() + "\n"
2023-10-02 14:21:08 +00:00
}
outString += ";; TXT Records\n"
for _, record := range z.TXTRecords {
2023-10-02 14:24:01 +00:00
outString += record.Render().String() + "\n"
2023-10-02 14:21:08 +00:00
}
return outString
}