Browse Source

dns: sort zones when writing data

Signed-off-by: Alejandro Mery <amery@jpi.io>
pull/35/head
Alejandro Mery 1 year ago
parent
commit
abe3005769
  1. 10
      pkg/dns/record.go
  2. 5
      pkg/dns/write.go

10
pkg/dns/record.go

@ -175,6 +175,16 @@ func (mgr *Manager) genRegionsSorted() []string {
return SortRegions(regions) return 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 { func (mgr *Manager) genAllAddrRecords() []AddrRecord {
var out []AddrRecord var out []AddrRecord

5
pkg/dns/write.go

@ -14,12 +14,13 @@ func (mgr *Manager) WriteTo(w io.Writer) (int64, error) {
cache := make(map[string][]netip.Addr) cache := make(map[string][]netip.Addr)
// zones // zones
for _, z := range mgr.zones { for _, zoneName := range mgr.genZonesSorted() {
z := mgr.zones[zoneName]
mgr.writeZoneHosts(&buf, z) mgr.writeZoneHosts(&buf, z)
// zone alias // zone alias
addrs := mgr.genZoneAddresses(z) addrs := mgr.genZoneAddresses(z)
zoneName := z.Name
rr := AddrRecord{ rr := AddrRecord{
Name: mgr.fqdn(zoneName + mgr.suffix), Name: mgr.fqdn(zoneName + mgr.suffix),

Loading…
Cancel
Save