diff options
author | 2021-10-09 01:34:22 +0800 | |
---|---|---|
committer | 2021-10-08 19:34:22 +0200 | |
commit | 0f5e7bdfb3264204c3726324bea98e590cc16de8 (patch) | |
tree | 332872bc028ab6f1ea76878b0d7401516a614308 /plugin | |
parent | 2c575a3d89a0b78b2dd317932c198df70ade3d7f (diff) | |
download | coredns-0f5e7bdfb3264204c3726324bea98e590cc16de8.tar.gz coredns-0f5e7bdfb3264204c3726324bea98e590cc16de8.tar.zst coredns-0f5e7bdfb3264204c3726324bea98e590cc16de8.zip |
plugin/forward: Use new msg.Id for upstream queries (#4841)
* restore 1.8.3 question revert logic; add tests (#4840)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
Signed-off-by: Vector <815926354@qq.com>
* change origin message id
Signed-off-by: Vector <815926354@qq.com>
Signed-off-by: IIvyPy <815926354@qq.com>
* Revert "restore 1.8.3 question revert logic; add tests (#4840)"
This reverts commit 95e44d91d03452556f5a8af64371fcf5f0b642d0.
Signed-off-by: IIvyPy <815926354@qq.com>
Co-authored-by: Chris O'Haver <cohaver@infoblox.com>
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/forward/connect.go | 13 |
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) |