resolver: store a name's CNAME once per nameserver (closes #220)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
For a name with a CNAME, a nameserver answers a query of any type with that CNAME, and the records of every answer were added, so the CNAME was stored once for each of the eight record types asked for. collectAnswerRecords now adds each value once per record type. A state file saved before this holds the repeated values. Load keeps each record value once, so the first check after upgrading sees no record change and notifies nothing for them. Model: opus-5-5
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -196,6 +197,19 @@ func (s *State) Load() error {
|
||||
return fmt.Errorf("parsing state file: %w", err)
|
||||
}
|
||||
|
||||
// A state file saved before each record value was stored once can
|
||||
// hold a hostname's CNAME once for every record type asked for.
|
||||
// Each value is kept once, so the first check does not see a
|
||||
// record change.
|
||||
for _, hs := range snapshot.Hostnames {
|
||||
for _, ns := range hs.RecordsByNameserver {
|
||||
for recordType, values := range ns.Records {
|
||||
slices.Sort(values)
|
||||
ns.Records[recordType] = slices.Compact(values)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s.snapshot = &snapshot
|
||||
s.log.Info("loaded state from disk", "path", path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user