mirror of
https://github.com/coredns/coredns.git
synced 2026-08-20 23:08:28 -04:00
plugin/hosts: pre-convert Origins to plugin.Zones in setup (#8383)
* test: add benchmark cases for Request IP/Port and parseRequest Signed-off-by: Manuel Rüger <manuel@rueg.eu> * test(kubernetes): add BenchmarkServices and BenchmarkServicesHeadless Signed-off-by: Manuel Rüger <manuel@rueg.eu> * perf(hosts): pre-convert Origins to plugin.Zones in hosts setup Signed-off-by: Manuel Rüger <manuel@rueg.eu> * style: fix gofmt trailing line formatting Signed-off-by: Manuel Rüger <manuel@rueg.eu> --------- Signed-off-by: Manuel Rüger <manuel@rueg.eu>
This commit is contained in:
@@ -17,6 +17,8 @@ type Hosts struct {
|
||||
Next plugin.Handler
|
||||
*Hostsfile
|
||||
|
||||
zones plugin.Zones
|
||||
|
||||
Fall fall.F
|
||||
|
||||
fallthroughUnsupported bool
|
||||
@@ -27,9 +29,13 @@ func (h Hosts) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (
|
||||
state := request.Request{W: w, Req: r}
|
||||
qname := state.Name()
|
||||
|
||||
answers := []dns.RR{}
|
||||
var answers []dns.RR
|
||||
|
||||
zone := plugin.Zones(h.Origins).Matches(qname)
|
||||
zones := h.zones
|
||||
if zones == nil {
|
||||
zones = plugin.Zones(h.Origins)
|
||||
}
|
||||
zone := zones.Matches(qname)
|
||||
if zone == "" {
|
||||
// PTR zones don't need to be specified in Origins.
|
||||
if state.QType() != dns.TypePTR {
|
||||
|
||||
Reference in New Issue
Block a user