fix(dnsserver): allow view server blocks in any declaration order (#8001)

When using the view plugin, filtered and unfiltered server blocks can
share the same zone and port. The zone overlap validation rejected this
configuration when the unfiltered block was not declared last, because
filtered configs treated an already-registered zone as an error.

Skip the 'already defined' check for configs that have filter functions,
since they are expected to coexist with an unfiltered catch-all block on
the same zone/port.

Fixes #7733

Signed-off-by: umut-polat <52835619+umut-polat@users.noreply.github.com>
This commit is contained in:
Umut Polat
2026-04-04 20:45:55 +03:00
committed by GitHub
parent 4eb6eca9f0
commit 2263340fab
3 changed files with 146 additions and 4 deletions

View File

@@ -237,11 +237,13 @@ func (h *dnsContext) validateZonesAndListeningAddresses() error {
akey := zoneAddr{Transport: conf.Transport, Zone: conf.Zone, Address: h, Port: conf.Port}
var existZone, overlapZone *zoneAddr
if len(conf.FilterFuncs) > 0 {
// This config has filters. Check for overlap with other (unfiltered) configs.
existZone, overlapZone = checker.check(akey)
// This config has filters (e.g. view plugin). It is allowed to
// share a zone/port with an unfiltered server block, so we only
// check without registering and skip the "already defined" error.
_, overlapZone = checker.check(akey)
} else {
// This config has no filters. Check for overlap with other (unfiltered) configs,
// and register the zone to prevent subsequent zones from overlapping with it.
// This config has no filters. Check for overlap with other
// unfiltered configs and register the zone.
existZone, overlapZone = checker.registerAndCheck(akey)
}
if existZone != nil {