diff options
author | 2018-12-16 21:48:09 +0000 | |
---|---|---|
committer | 2018-12-16 13:48:09 -0800 | |
commit | 775cf92f038f32fc1e562f61c0fcaaaea9ea5b7e (patch) | |
tree | 8b194c0ef9766d8d83be3f9e455d3d943ac5a327 /plugin/loop/loop.go | |
parent | 6b8c154441f4f4bcf5c8ee6cff888d28edac81fe (diff) | |
download | coredns-775cf92f038f32fc1e562f61c0fcaaaea9ea5b7e.tar.gz coredns-775cf92f038f32fc1e562f61c0fcaaaea9ea5b7e.tar.zst coredns-775cf92f038f32fc1e562f61c0fcaaaea9ea5b7e.zip |
plugin/loop: show from -> to (#2400)
Show from and to address when detecting a loop they may aid in
debugging.
Hard to create a unit test, but this is a startup run with self induced
loop:
~~~ corefile
.:1053 {
loop
log
forward . 127.0.0.1:1053
}
~~~~
~~~
:1053
2018-12-16T10:11:03.695Z [INFO] CoreDNS-1.3.0
2018-12-16T10:11:03.695Z [INFO] linux/amd64, go1.11,
CoreDNS-1.3.0
linux/amd64, go1.11,
2018-12-16T10:11:03.696Z [FATAL] plugin/loop: Loop (127.0.0.1:51384 -> :1053) detected for zone ".", see https://coredns.io/plugins/loop#troubleshooting. Query: "HINFO 2781022615773629442.4133547885299871809."
~~~
Update the docs and polished that a bit as well.
Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin/loop/loop.go')
-rw-r--r-- | plugin/loop/loop.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/plugin/loop/loop.go b/plugin/loop/loop.go index 45bdc4267..8d29798ad 100644 --- a/plugin/loop/loop.go +++ b/plugin/loop/loop.go @@ -19,6 +19,7 @@ type Loop struct { zone string qname string + addr string sync.RWMutex i int @@ -49,7 +50,7 @@ func (l *Loop) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) ( } if l.seen() > 2 { - log.Fatalf("Forwarding loop detected in \"%s\" zone. Exiting. See https://coredns.io/plugins/loop#troubleshooting. Probe query: \"HINFO %s\".", l.zone, l.qname) + 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) } return plugin.NextOrFailure(l.Name(), l.Next, ctx, w, r) @@ -94,3 +95,15 @@ func (l *Loop) disabled() bool { defer l.RUnlock() return l.off } + +func (l *Loop) setAddress(addr string) { + l.Lock() + defer l.Unlock() + l.addr = addr +} + +func (l *Loop) address() string { + l.RLock() + defer l.RUnlock() + return l.addr +} |