refactor(api): use audit operation constants and the shared zone not found error in zone handlers
- refactor(api): use audit operation constants and the shared zone not found error in zone handlers - fix(api): return the stored content of rows with check errors - fix(api): return warnings from record deletes, zone creation and import apply - fix(api): allow repairing rows stored with a non canonical zone and invalid SOA sets - fix(check): accept JSON column formatting and an absent SOA serial as canonical content - fix(ui): match audit diff items by identity instead of array index - fix(ui): count the SOA change once, report import warnings and check the request size - fix(ui): edit the selected SOA row, keep the server order, show error rows raw and report write warnings - test(check): cover triggering and clean pairs with exact codes and record ids - test(records): cover SRV port, SOA timer and CAA value boundaries - test(cli): check the exact check output and the exit code of warning-only zones - refactor(import): order current rows with cmp.Compare - test(check): cover malformed stored content and a mailbox stored as an address - test(api): cover zone write failure paths, ambiguous SOA updates and unchanged record detection
This commit is contained in:
1 parent
53444bec7a
commit
a7ba01fc77
21 files changed
+1315
-170
No files matched your search
@@ -68,21 +68,27 @@ func updateSOASerial(current []recordRow, changes zoneChanges, now time.Time) (*
|
||||
if changes.empty() {
|
||||
return nil, nil
|
||||
}
|
||||
var original *recordRow
|
||||
original := make(map[int64]recordRow)
|
||||
for _, row := range current {
|
||||
if row.RecordType != "SOA" {
|
||||
continue
|
||||
if row.RecordType == "SOA" {
|
||||
original[row.ID] = row
|
||||
}
|
||||
if original != nil {
|
||||
return nil, errors.New("cannot determine serial with multiple SOA records")
|
||||
}
|
||||
original = &row
|
||||
}
|
||||
if original == nil {
|
||||
var soa []recordRow
|
||||
for _, row := range changes.finalRows(current) {
|
||||
if row.RecordType == "SOA" {
|
||||
soa = append(soa, row)
|
||||
}
|
||||
}
|
||||
if len(soa) != 1 {
|
||||
return nil, nil
|
||||
}
|
||||
before, ok := original[soa[0].ID]
|
||||
if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
serial, _ := storedSOASerial(*original)
|
||||
serial, _ := storedSOASerial(before)
|
||||
switch {
|
||||
case serial != 0:
|
||||
serial = nextSOASerial(serial, now)
|
||||
@@ -91,16 +97,7 @@ func updateSOASerial(current []recordRow, changes zoneChanges, now time.Time) (*
|
||||
default:
|
||||
return nil, nil
|
||||
}
|
||||
row := *original
|
||||
for _, updated := range changes.Updates {
|
||||
if updated.ID == original.ID {
|
||||
row = updated
|
||||
}
|
||||
}
|
||||
if changes.SOAUpdate != nil {
|
||||
row = *changes.SOAUpdate
|
||||
}
|
||||
row, err := withSOASerial(row, serial, true)
|
||||
row, err := withSOASerial(soa[0], serial, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user