Merge pull request 'dns: sort zones when writing data' (#35)

Reviewed-on: #35
This commit was merged in pull request #35.
This commit is contained in:
2023-10-30 19:41:16 +01:00
2 changed files with 13 additions and 2 deletions
+10
View File
@@ -151,6 +151,16 @@ func (mgr *Manager) genRegionsSorted() []string {
return cluster.SortRegions(regions)
}
func (mgr *Manager) genZonesSorted() []string {
zones := make([]string, 0, len(mgr.zones))
for name := range mgr.zones {
zones = append(zones, name)
}
sort.Strings(zones)
return zones
}
func (mgr *Manager) genAllAddrRecords() []AddrRecord {
var out []AddrRecord
+3 -2
View File
@@ -14,12 +14,13 @@ func (mgr *Manager) WriteTo(w io.Writer) (int64, error) {
cache := make(map[string][]netip.Addr)
// zones
for _, z := range mgr.zones {
for _, zoneName := range mgr.genZonesSorted() {
z := mgr.zones[zoneName]
mgr.writeZoneHosts(&buf, z)
// zone alias
addrs := mgr.genZoneAddresses(z)
zoneName := z.Name
rr := AddrRecord{
Name: mgr.fqdn(zoneName + mgr.suffix),