Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions records.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion records_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down