mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 02:33:14 -04:00
Fix context passing (#2681)
This commit is contained in:
committed by
Miek Gieben
parent
26e4026ec1
commit
f798d18bdd
@@ -44,12 +44,6 @@ const (
|
||||
DnstapSendOption ContextKey = "dnstap-send-option"
|
||||
)
|
||||
|
||||
// TapperFromContext will return a Tapper if the dnstap plugin is enabled.
|
||||
func TapperFromContext(ctx context.Context) (t Tapper) {
|
||||
t, _ = ctx.(Tapper)
|
||||
return
|
||||
}
|
||||
|
||||
// TapMessage implements Tapper.
|
||||
func (h Dnstap) TapMessage(m *tap.Message) {
|
||||
t := tap.Dnstap_MESSAGE
|
||||
@@ -71,6 +65,7 @@ func (h Dnstap) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
|
||||
// message to be sent out
|
||||
sendOption := taprw.SendOption{Cq: true, Cr: true}
|
||||
newCtx := context.WithValue(ctx, DnstapSendOption, &sendOption)
|
||||
newCtx = ContextWithTapper(newCtx, h)
|
||||
|
||||
rw := &taprw.ResponseWriter{
|
||||
ResponseWriter: w,
|
||||
@@ -80,7 +75,7 @@ func (h Dnstap) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
|
||||
QueryEpoch: time.Now(),
|
||||
}
|
||||
|
||||
code, err := plugin.NextOrFailure(h.Name(), h.Next, tapContext{newCtx, h}, rw, r)
|
||||
code, err := plugin.NextOrFailure(h.Name(), h.Next, newCtx, rw, r)
|
||||
if err != nil {
|
||||
// ignore dnstap errors
|
||||
return code, err
|
||||
|
||||
Reference in New Issue
Block a user