mirror of
https://github.com/coolsnowwolf/packages.git
synced 2025-05-02 14:21:24 +08:00
28 lines
1.2 KiB
Diff
28 lines
1.2 KiB
Diff
From 653c7a03222d9135a6f9bfbeff3aaddc300762b4 Mon Sep 17 00:00:00 2001
|
|
From: IrineSistiana <49315432+IrineSistiana@users.noreply.github.com>
|
|
Date: Thu, 6 Jan 2022 19:59:33 +0800
|
|
Subject: [PATCH] fixed #240
|
|
|
|
---
|
|
dispatcher/plugin/executable/forward/forward.go | 9 +++++++--
|
|
1 file changed, 7 insertions(+), 2 deletions(-)
|
|
|
|
--- a/dispatcher/plugin/executable/forward/forward.go
|
|
+++ b/dispatcher/plugin/executable/forward/forward.go
|
|
@@ -158,8 +158,13 @@ func (f *forwardPlugin) Exec(ctx context
|
|
func (f *forwardPlugin) exec(ctx context.Context, qCtx *handler.Context) error {
|
|
var r *dns.Msg
|
|
var err error
|
|
- if f.fastIPHandler != nil {
|
|
- r, _, err = f.fastIPHandler.ExchangeFastest(qCtx.Q().Copy(), f.upstreams)
|
|
+ q := qCtx.Q()
|
|
+ if f.fastIPHandler != nil && len(q.Question) == 1 {
|
|
+ // Only call ExchangeFastest if the query has one question.
|
|
+ // ExchangeFastest will use the first question name as host name.
|
|
+ // It won't check questions range. So it will it panic if len(q.Question) == 0.
|
|
+ // Ref: https://github.com/IrineSistiana/mosdns/issues/240
|
|
+ r, _, err = f.fastIPHandler.ExchangeFastest(q.Copy(), f.upstreams)
|
|
} else {
|
|
r, err = f.bu.ExchangeParallel(ctx, qCtx)
|
|
}
|