diff --git a/records.go b/records.go index 4a414f7..ae827f8 100644 --- a/records.go +++ b/records.go @@ -75,3 +75,21 @@ func New() *Records { re.m = make(map[string][]dns.RR) return re } + +func (re *Records) Lookup(z string, st request.Request) dns.RR { + for _, rr := range re.All(z) { + if h := rr.Header(); h.Name == st.QName() && h.Rrtype == st.QType() && h.Class == st.QClass() { + return rr + } + } + return nil +} + +func (re *Records) All(z string) []dns.RR { + if zone := plugin.Zones(re.origins).Matches(z); zone != "" { + if records, ok := re.m[zone]; ok { + return records + } + } + return nil +} diff --git a/records_test.go b/records_test.go index ef9d11d..fdee0f8 100644 --- a/records_test.go +++ b/records_test.go @@ -4,10 +4,10 @@ import ( "context" "testing" + "github.com/coredns/caddy" "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" - "github.com/caddyserver/caddy" "github.com/miekg/dns" )