diff options
author | 2019-04-23 16:21:28 +0100 | |
---|---|---|
committer | 2019-04-23 23:21:28 +0800 | |
commit | 3adfeaa8572fdde8e066da2c4e2239b0a3ea7388 (patch) | |
tree | 55b5bf153b534be0c253e751bb9cd1e4bbb2ad04 /plugin | |
parent | 2c418b9fd50de1f7606eaf138f38be3da8586135 (diff) | |
download | coredns-3adfeaa8572fdde8e066da2c4e2239b0a3ea7388.tar.gz coredns-3adfeaa8572fdde8e066da2c4e2239b0a3ea7388.tar.zst coredns-3adfeaa8572fdde8e066da2c4e2239b0a3ea7388.zip |
plugin/chaos: randomize author list (#2794)
Randomize the author list on request; keep the zowners.go file stable so
a 'go generate' remain stable.
chaos.Owners could potentially be a map and be randomized by ranging
over it, but this seems simpler and fewer lines of code.
Bit of Easter hacking; seems more fair to randomize this list.
Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/chaos/chaos.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/plugin/chaos/chaos.go b/plugin/chaos/chaos.go index 42b1fb3f0..f4d758a7b 100644 --- a/plugin/chaos/chaos.go +++ b/plugin/chaos/chaos.go @@ -3,7 +3,9 @@ package chaos import ( "context" + "math/rand" "os" + "time" "github.com/coredns/coredns/plugin" "github.com/coredns/coredns/request" @@ -34,8 +36,10 @@ func (c Chaos) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) ( 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}}) + rnd := rand.New(rand.NewSource(time.Now().Unix())) + + for _, i := range rnd.Perm(len(c.Authors)) { + m.Answer = append(m.Answer, &dns.TXT{Hdr: hdr, Txt: []string{c.Authors[i]}}) } case "version.bind.", "version.server.": m.Answer = []dns.RR{&dns.TXT{Hdr: hdr, Txt: []string{c.Version}}} |