MCPcopy
hub / github.com/coredns/coredns / ServeDNS

Method ServeDNS

plugin/loop/loop.go:33–57  ·  view source on GitHub ↗

ServeDNS implements the plugin.Handler interface.

(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)

Source from the content-addressed store, hash-verified

31
32// ServeDNS implements the plugin.Handler interface.
33func (l *Loop) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
34 if r.Question[0].Qtype != dns.TypeHINFO {
35 return plugin.NextOrFailure(l.Name(), l.Next, ctx, w, r)
36 }
37 if l.disabled() {
38 return plugin.NextOrFailure(l.Name(), l.Next, ctx, w, r)
39 }
40
41 state := request.Request{W: w, Req: r}
42
43 zone := plugin.Zones([]string{l.zone}).Matches(state.Name())
44 if zone == "" {
45 return plugin.NextOrFailure(l.Name(), l.Next, ctx, w, r)
46 }
47
48 if state.Name() == l.qname {
49 l.inc()
50 }
51
52 if l.seen() > 2 {
53 log.Fatalf(`Loop (%s -> %s) detected for zone %q, see https://coredns.io/plugins/loop#troubleshooting. Query: "HINFO %s"`, state.RemoteAddr(), l.address(), l.zone, l.qname)
54 }
55
56 return plugin.NextOrFailure(l.Name(), l.Next, ctx, w, r)
57}
58
59// Name implements the plugin.Handler interface.
60func (l *Loop) Name() string { return "loop" }

Callers

nothing calls this directly

Calls 11

NameMethod · 0.95
disabledMethod · 0.95
NameMethod · 0.95
incMethod · 0.95
seenMethod · 0.95
RemoteAddrMethod · 0.95
addressMethod · 0.95
NextOrFailureFunction · 0.92
ZonesTypeAlias · 0.92
FatalfFunction · 0.92
MatchesMethod · 0.45

Tested by

no test coverage detected