mirror of
https://github.com/coredns/coredns.git
synced 2026-04-05 03:35:33 -04:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user