MCPcopy
hub / github.com/coredns/coredns / setup

Function setup

plugin/forward/setup.go:29–71  ·  view source on GitHub ↗
(c *caddy.Controller)

Source from the content-addressed store, hash-verified

27}
28
29func setup(c *caddy.Controller) error {
30 fs, err := parseForward(c)
31 if err != nil {
32 return plugin.Error("forward", err)
33 }
34 for i := range fs {
35 f := fs[i]
36 if len(f.toEntries) > max {
37 return plugin.Error("forward", fmt.Errorf("more than %d TOs configured: %d", max, len(f.toEntries)))
38 }
39
40 if i == len(fs)-1 {
41 // last forward: point next to next plugin
42 dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
43 f.Next = next
44 return f
45 })
46 } else {
47 // middle forward: point next to next forward
48 nextForward := fs[i+1]
49 dnsserver.GetConfig(c).AddPlugin(func(plugin.Handler) plugin.Handler {
50 f.Next = nextForward
51 return f
52 })
53 }
54
55 c.OnStartup(func() error {
56 return f.OnStartup()
57 })
58 c.OnStartup(func() error {
59 if taph := dnsserver.GetConfig(c).Handler("dnstap"); taph != nil {
60 f.SetTapPlugin(taph.(*dnstap.Dnstap))
61 }
62 return nil
63 })
64
65 c.OnShutdown(func() error {
66 return f.OnShutdown()
67 })
68 }
69
70 return nil
71}
72
73// OnStartup starts a goroutines for all proxies.
74func (f *Forward) OnStartup() (err error) {

Callers 2

TestMultiForwardFunction · 0.70
TestSetTapPluginFunction · 0.70

Calls 9

ErrorFunction · 0.92
GetConfigFunction · 0.92
parseForwardFunction · 0.85
AddPluginMethod · 0.80
SetTapPluginMethod · 0.80
ErrorfMethod · 0.65
OnStartupMethod · 0.45
HandlerMethod · 0.45
OnShutdownMethod · 0.45

Tested by 2

TestMultiForwardFunction · 0.56
TestSetTapPluginFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…