aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'plugin')
-rw-r--r--plugin/forward/connect.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/plugin/forward/connect.go b/plugin/forward/connect.go
index 63a0bfe50..164ac89a0 100644
--- a/plugin/forward/connect.go
+++ b/plugin/forward/connect.go
@@ -97,6 +97,13 @@ func (p *Proxy) Connect(ctx context.Context, state request.Request, opts options
}
pc.c.SetWriteDeadline(time.Now().Add(maxTimeout))
+ // records the origin Id before upstream.
+ originId := state.Req.Id
+ state.Req.Id = dns.Id()
+ defer func(){
+ state.Req.Id = originId
+ }()
+
if err := pc.c.WriteMsg(state.Req); err != nil {
pc.c.Close() // not giving it back
if err == io.EOF && cached {
@@ -114,6 +121,10 @@ func (p *Proxy) Connect(ctx context.Context, state request.Request, opts options
if err == io.EOF && cached {
return nil, ErrCachedClosed
}
+ // recovery the origin Id after upstream.
+ if ret != nil{
+ ret.Id = originId
+ }
return ret, err
}
// drop out-of-order responses
@@ -121,6 +132,8 @@ func (p *Proxy) Connect(ctx context.Context, state request.Request, opts options
break
}
}
+ // recovery the origin Id after upstream.
+ ret.Id = originId
p.transport.Yield(pc)