mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 10:43:17 -04:00
plugin/forward: fix broken tap plugins when dnstap plugins specified (#5890)
* plugin/forward: fix broken tap plugins when dnstap plugins specified --------- Signed-off-by: Gerhard Tan <gwohau.tan@gmail.com>
This commit is contained in:
@@ -14,9 +14,6 @@ import (
|
||||
|
||||
// toDnstap will send the forward and received message to the dnstap plugin.
|
||||
func toDnstap(f *Forward, host string, state request.Request, opts options, reply *dns.Msg, start time.Time) {
|
||||
// Query
|
||||
q := new(tap.Message)
|
||||
msg.SetQueryTime(q, start)
|
||||
h, p, _ := net.SplitHostPort(host) // this is preparsed and can't err here
|
||||
port, _ := strconv.ParseUint(p, 10, 32) // same here
|
||||
ip := net.ParseIP(h)
|
||||
@@ -34,12 +31,14 @@ func toDnstap(f *Forward, host string, state request.Request, opts options, repl
|
||||
ta = &net.TCPAddr{IP: ip, Port: int(port)}
|
||||
}
|
||||
|
||||
// Forwarder dnstap messages are from the perspective of the downstream server
|
||||
// (upstream is the forward server)
|
||||
msg.SetQueryAddress(q, state.W.RemoteAddr())
|
||||
msg.SetResponseAddress(q, ta)
|
||||
|
||||
for _, t := range f.tapPlugins {
|
||||
// Query
|
||||
q := new(tap.Message)
|
||||
msg.SetQueryTime(q, start)
|
||||
// Forwarder dnstap messages are from the perspective of the downstream server
|
||||
// (upstream is the forward server)
|
||||
msg.SetQueryAddress(q, state.W.RemoteAddr())
|
||||
msg.SetResponseAddress(q, ta)
|
||||
if t.IncludeRawMessage {
|
||||
buf, _ := state.Req.Pack()
|
||||
q.QueryMessage = buf
|
||||
|
||||
Reference in New Issue
Block a user