handleExchangeResult handles the result after the upstream exchange. It sets resp and the upstream that has resolved the request in d. Also, it clears the AA bit in the upstream response. If resp is nil, it generates a server failure response. req must not be nil.
( ctx context.Context, d *DNSContext, req *dns.Msg, resp *dns.Msg, u upstream.Upstream, )
| 642 | // the AA bit in the upstream response. If resp is nil, it generates a server |
| 643 | // failure response. req must not be nil. |
| 644 | func (p *Proxy) handleExchangeResult( |
| 645 | ctx context.Context, |
| 646 | d *DNSContext, |
| 647 | req *dns.Msg, |
| 648 | resp *dns.Msg, |
| 649 | u upstream.Upstream, |
| 650 | ) { |
| 651 | if resp == nil || len(resp.Question) != 1 { |
| 652 | d.Res = p.messages.NewMsgSERVFAIL(req) |
| 653 | d.hasEDNS0 = false |
| 654 | |
| 655 | return |
| 656 | } |
| 657 | |
| 658 | d.Upstream = u |
| 659 | d.Res = resp |
| 660 | d.Res.Authoritative = false |
| 661 | |
| 662 | p.setMinMaxTTL(ctx, resp) |
| 663 | } |
| 664 | |
| 665 | // addDO adds EDNS0 RR if needed and sets DO bit of msg to true. msg must not |
| 666 | // be nil. |
no test coverage detected