plugin: use Zones.Contains when any match suffices (#8505)

This commit is contained in:
Ilya Kulakov
2026-09-02 23:59:58 -07:00
committed by GitHub
parent f1d835aa51
commit c942ca7c36
16 changed files with 25 additions and 30 deletions

View File

@@ -35,8 +35,7 @@ func (h Hosts) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (
if zones == nil {
zones = plugin.Zones(h.Origins)
}
zone := zones.Matches(qname)
if zone == "" {
if !zones.Contains(qname) {
// PTR zones don't need to be specified in Origins.
if state.QType() != dns.TypePTR {
// if this doesn't match we need to fall through regardless of h.Fallthrough

View File

@@ -202,7 +202,7 @@ func (h *Hostsfile) parse(r io.Reader) *Map {
for i := 1; i < len(f); i++ {
name := plugin.Name(string(f[i])).Normalize()
if plugin.Zones(h.Origins).Matches(name) == "" {
if !plugin.Zones(h.Origins).Contains(name) {
// name is not in Origins
continue
}