Debian Codegraph @

cmd/atomdns/handlers/chaos/setup.go

raw
1 package chaos
2
3 import (
4 "strings"
5
6 "codeberg.org/miekg/dns/cmd/atomdns/internal/dnsserver"
7 )
8
9 const Version = "Served by atomdns, https://atomdns.miek.nl"
10
11 func (c *Chaos) Setup(co *dnsserver.Controller) error {
12 c.Version = Version
13 if co.Next() {
14 args := co.RemainingArgs()
15 if len(args) > 1 {
16 return co.ArgErr()
17 }
18 if len(args) == 1 {
19 c.Version = args[0]
20 }
21 authors := []string{}
22 for co.NextBlock(0) {
23 switch co.Val() {
24 case "authors":
25 for co.NextBlock(1) {
26 authors = append(authors, strings.TrimSpace(co.Val()))
27 for co.NextLine() {
28 if co.Val() == "}" {
29 break
30 }
31 authors = append(authors, strings.TrimSpace(co.Val()))
32 }
33 }
34 default:
35 return co.PropErr()
36 }
37 }
38 if len(authors) > 0 {
39 c.Authors = authors
40 }
41 }
42 return nil
43 }