aboutsummaryrefslogtreecommitdiff
path: root/plugin/any/any.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2019-04-28 11:46:45 +0100
committerGravatar GitHub <noreply@github.com> 2019-04-28 11:46:45 +0100
commit39bc2af5092a64f6ac7c9d2ff7ba2bded8f682c8 (patch)
treed72ee7f5fced3aadf4347e3ff0a73ea0b9024ad8 /plugin/any/any.go
parent4f7fb98284f9e3a24232af921ddc5bf852e998da (diff)
downloadcoredns-39bc2af5092a64f6ac7c9d2ff7ba2bded8f682c8.tar.gz
coredns-39bc2af5092a64f6ac7c9d2ff7ba2bded8f682c8.tar.zst
coredns-39bc2af5092a64f6ac7c9d2ff7ba2bded8f682c8.zip
Add any plugin (#2801)
* Add any plugin This adds the any plugin, a plain copy of coredns/any documented here https://coredns.io/explugins/any/ as an external plugin. Fixes: #2785 Signed-off-by: Miek Gieben <miek@miek.nl> * Stickler bot nit Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin/any/any.go')
-rw-r--r--plugin/any/any.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/plugin/any/any.go b/plugin/any/any.go
new file mode 100644
index 000000000..9a05e37b2
--- /dev/null
+++ b/plugin/any/any.go
@@ -0,0 +1,32 @@
+package any
+
+import (
+ "context"
+
+ "github.com/coredns/coredns/plugin"
+
+ "github.com/miekg/dns"
+)
+
+// Any is a plugin that returns a HINFO reply to ANY queries.
+type Any struct {
+ Next plugin.Handler
+}
+
+// ServeDNS implements the plugin.Handler interface.
+func (a Any) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
+ if r.Question[0].Qtype != dns.TypeANY {
+ return plugin.NextOrFailure(a.Name(), a.Next, ctx, w, r)
+ }
+
+ m := new(dns.Msg)
+ m.SetReply(r)
+ hdr := dns.RR_Header{Name: r.Question[0].Name, Ttl: 8482, Class: dns.ClassINET, Rrtype: dns.TypeHINFO}
+ m.Answer = []dns.RR{&dns.HINFO{Hdr: hdr, Cpu: "ANY obsoleted", Os: "See RFC 8482"}}
+
+ w.WriteMsg(m)
+ return 0, nil
+}
+
+// Name implements the Handler interface.
+func (a Any) Name() string { return "any" }