dns: Manager.WriteTo() generates BIND config, fully qualifies

Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
2023-09-12 15:14:53 +00:00
parent f5ea72740c
commit 1a47985bd7
2 changed files with 79 additions and 0 deletions
+17
View File
@@ -12,6 +12,10 @@ import (
"github.com/libdns/libdns"
)
func (mgr *Manager) fqdn(name string) string {
return fmt.Sprintf("%s.%s.", name, mgr.domain)
}
// SortAddrSlice sorts a slice of [netip.Addr]
func SortAddrSlice(s []netip.Addr) []netip.Addr {
sort.Slice(s, func(i, j int) bool {
@@ -193,3 +197,16 @@ func (mgr *Manager) genZoneHostRecords(z *Zone) []AddrRecord {
SortAddrRecords(out)
return out
}
func (mgr *Manager) genRegionAddressesCached(name string,
zones map[string][]netip.Addr) []netip.Addr {
//
var addrs []netip.Addr
for _, zoneName := range mgr.regions[name] {
addrs = append(addrs, zones[zoneName]...)
}
SortAddrSlice(addrs)
return addrs
}