diff options
author | 2019-07-23 18:32:44 +0000 | |
---|---|---|
committer | 2019-07-23 18:32:44 +0000 | |
commit | eba020e6a1176c0d8fed639e936ddc2774f295dd (patch) | |
tree | adce0be527c6a0d412d74a120b086f90a5503bbf /plugin/file/rrutil/util.go | |
parent | 637bd3c7dcb19659e3e52cd56fe8f4e6b455ac83 (diff) | |
download | coredns-eba020e6a1176c0d8fed639e936ddc2774f295dd.tar.gz coredns-eba020e6a1176c0d8fed639e936ddc2774f295dd.tar.zst coredns-eba020e6a1176c0d8fed639e936ddc2774f295dd.zip |
plugin/file: simplify locking (#3024)
* plugin/file: simplify locking
Simplify the locking, remove the reloadMu and just piggyback on the
other lock for accessing content, which assumes things can be move
underneath.
Copy the Apex and Zone to new vars to make sure the pointer isn't
updated from under us.
The releadMu isn't need at all, the time.Ticker firing while we're
reading means we will just miss that tick and get it on the next go.
Add rrutil subpackage and put some more generic functions in there, that
are now used from file and the tree package. This removes some
duplication.
Rename additionalProcessing that didn't actually do that to
externalLookup, because that's what being done at some point.
Signed-off-by: Miek Gieben <miek@miek.nl>
* Update plugin/file/lookup.go
Co-Authored-By: Michael Grosser <development@stp-ip.net>
Diffstat (limited to 'plugin/file/rrutil/util.go')
-rw-r--r-- | plugin/file/rrutil/util.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/plugin/file/rrutil/util.go b/plugin/file/rrutil/util.go new file mode 100644 index 000000000..63e447196 --- /dev/null +++ b/plugin/file/rrutil/util.go @@ -0,0 +1,29 @@ +// Package rrutil provides function to find certain RRs in slices. +package rrutil + +import "github.com/miekg/dns" + +// SubTypeSignature returns the RRSIG for the subtype. +func SubTypeSignature(rrs []dns.RR, subtype uint16) []dns.RR { + sigs := []dns.RR{} + // there may be multiple keys that have signed this subtype + for _, sig := range rrs { + if s, ok := sig.(*dns.RRSIG); ok { + if s.TypeCovered == subtype { + sigs = append(sigs, s) + } + } + } + return sigs +} + +// CNAMEForType returns the RR that have the qtype from targets. +func CNAMEForType(rrs []dns.RR, qtype uint16) []dns.RR { + ret := []dns.RR{} + for _, target := range rrs { + if target.Header().Rrtype == qtype { + ret = append(ret, target) + } + } + return ret +} |