* plugin/chaos: add default list of authors Add a owners_generate.go that generates a Owners variables for use in the chaos plugin. Add a default list of authors in the authors.bind CH zone. When doing a query this now returns: ~~~ sh % dig authors.bind TXT CH ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5456 ;; flags: qr rd; QUERY: 1, ANSWER: 22, AUTHORITY: 0, ADDITIONAL: 1 ;; WARNING: recursion requested but not available ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;authors.bind. CH TXT ;; ANSWER SECTION: authors.bind. 0 CH TXT "bradbeam" authors.bind. 0 CH TXT "chrisohaver" authors.bind. 0 CH TXT "dilyevsky" authors.bind. 0 CH TXT "ekleiner" authors.bind. 0 CH TXT "fastest963" authors.bind. 0 CH TXT "fturib" authors.bind. 0 CH TXT "greenpau" authors.bind. 0 CH TXT "grobie" authors.bind. 0 CH TXT "inigohu" authors.bind. 0 CH TXT "isolus" authors.bind. 0 CH TXT "johnbelamaric" authors.bind. 0 CH TXT "miekg" authors.bind. 0 CH TXT "nchrisdk" authors.bind. 0 CH TXT "nitisht" authors.bind. 0 CH TXT "pmoroney" authors.bind. 0 CH TXT "rajansandeep" authors.bind. 0 CH TXT "rdrozhdzh" authors.bind. 0 CH TXT "rtreffer" authors.bind. 0 CH TXT "stp-ip" authors.bind. 0 CH TXT "superq" authors.bind. 0 CH TXT "varyoo" authors.bind. 0 CH TXT "yongtang" ~~~ This was hard to do previously as we didn't hardcode this in the source, but now with OWNERS files we can just generate this list. Privacy wise this isn't worse than being listed in OWNERS file in the first place. And it's a nice hat tip to the people making CoreDNS better. Signed-off-by: Miek Gieben <miek@miek.nl> * Sticklet bot comments Signed-off-by: Miek Gieben <miek@miek.nl>
54 lines
1.5 KiB
Go
54 lines
1.5 KiB
Go
// Package chaos implements a plugin that answer to 'CH version.bind TXT' type queries.
|
|
package chaos
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
|
|
"github.com/coredns/coredns/plugin"
|
|
"github.com/coredns/coredns/request"
|
|
|
|
"github.com/miekg/dns"
|
|
)
|
|
|
|
// Chaos allows CoreDNS to reply to CH TXT queries and return author or
|
|
// version information.
|
|
type Chaos struct {
|
|
Next plugin.Handler
|
|
Version string
|
|
Authors []string
|
|
}
|
|
|
|
// ServeDNS implements the plugin.Handler interface.
|
|
func (c Chaos) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
|
|
state := request.Request{W: w, Req: r}
|
|
if state.QClass() != dns.ClassCHAOS || state.QType() != dns.TypeTXT {
|
|
return plugin.NextOrFailure(c.Name(), c.Next, ctx, w, r)
|
|
}
|
|
|
|
m := new(dns.Msg)
|
|
m.SetReply(r)
|
|
|
|
hdr := dns.RR_Header{Name: state.QName(), Rrtype: dns.TypeTXT, Class: dns.ClassCHAOS, Ttl: 0}
|
|
switch state.Name() {
|
|
default:
|
|
return plugin.NextOrFailure(c.Name(), c.Next, ctx, w, r)
|
|
case "authors.bind.":
|
|
for _, a := range c.Authors {
|
|
m.Answer = append(m.Answer, &dns.TXT{Hdr: hdr, Txt: []string{a}})
|
|
}
|
|
case "version.bind.", "version.server.":
|
|
m.Answer = []dns.RR{&dns.TXT{Hdr: hdr, Txt: []string{c.Version}}}
|
|
case "hostname.bind.", "id.server.":
|
|
hostname, err := os.Hostname()
|
|
if err != nil {
|
|
hostname = "localhost"
|
|
}
|
|
m.Answer = []dns.RR{&dns.TXT{Hdr: hdr, Txt: []string{trim(hostname)}}}
|
|
}
|
|
w.WriteMsg(m)
|
|
return 0, nil
|
|
}
|
|
|
|
// Name implements the Handler interface.
|
|
func (c Chaos) Name() string { return "chaos" }
|