diff --git a/coredns_plugin/coredns_plugin.go b/coredns_plugin/coredns_plugin.go index 5209e37b..f937cb84 100644 --- a/coredns_plugin/coredns_plugin.go +++ b/coredns_plugin/coredns_plugin.go @@ -41,16 +41,6 @@ func init() { }) } -type cacheEntry struct { - answer []dns.RR - lastUpdated time.Time -} - -var ( - lookupCacheTime = time.Minute * 30 - lookupCache = map[string]cacheEntry{} -) - type plugFilter struct { ID int64 Path string @@ -345,29 +335,20 @@ func (p *plug) replaceHostWithValAndReply(ctx context.Context, w dns.ResponseWri records = append(records, result) } else { // this is a domain name, need to look it up - cacheentry := lookupCache[val] - if time.Since(cacheentry.lastUpdated) > lookupCacheTime { - req := new(dns.Msg) - req.SetQuestion(dns.Fqdn(val), question.Qtype) - req.RecursionDesired = true - reqstate := request.Request{W: w, Req: req, Context: ctx} - result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType()) - if err != nil { - log.Printf("Got error %s\n", err) - return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err) + req := new(dns.Msg) + req.SetQuestion(dns.Fqdn(val), question.Qtype) + req.RecursionDesired = true + reqstate := request.Request{W: w, Req: req, Context: ctx} + result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType()) + if err != nil { + log.Printf("Got error %s\n", err) + return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err) + } + if result != nil { + for _, answer := range result.Answer { + answer.Header().Name = question.Name } - if result != nil { - for _, answer := range result.Answer { - answer.Header().Name = question.Name - } - records = result.Answer - cacheentry.answer = result.Answer - cacheentry.lastUpdated = time.Now() - lookupCache[val] = cacheentry - } - } else { - // get from cache - records = cacheentry.answer + records = result.Answer } } m := new(dns.Msg) diff --git a/dnsfilter/dnsfilter.go b/dnsfilter/dnsfilter.go index 5fb5d0ed..c34cd590 100644 --- a/dnsfilter/dnsfilter.go +++ b/dnsfilter/dnsfilter.go @@ -17,7 +17,6 @@ import ( "sync/atomic" "time" - _ "github.com/benburkert/dns/init" "github.com/bluele/gcache" "golang.org/x/net/publicsuffix" )