diff --git a/inbound/handler.go b/inbound/handler.go index c6d922b..050b41b 100644 --- a/inbound/handler.go +++ b/inbound/handler.go @@ -241,7 +241,7 @@ func (h *handlerImpl) handle(writer dns.ResponseWriter, req *dns.Msg) (resp *dns _info.matched = matched // redirect - if resp != nil && h.redirector != nil { + if resp != nil { if group := h.redirector(matched, req, resp); group != nil { matched = group resp = group.Handle(req) diff --git a/redirector/redirector.go b/redirector/redirector.go index 123e402..bbed5eb 100644 --- a/redirector/redirector.go +++ b/redirector/redirector.go @@ -3,14 +3,15 @@ package redirector import ( "bufio" "fmt" + "net" + "os" + "strings" + "github.com/miekg/dns" "github.com/sirupsen/logrus" "github.com/wolf-joe/ts-dns/config" "github.com/wolf-joe/ts-dns/outbound" "github.com/yl2chen/cidranger" - "net" - "os" - "strings" ) const ( @@ -49,7 +50,7 @@ func NewRedirector(globalConf config.Conf, groups map[string]outbound.IGroup) (R // return runtime redirector redirector := func(src outbound.IGroup, req, resp *dns.Msg) outbound.IGroup { instance, exists := group2redir[src.Name()] - if !exists { + if resp == nil || !exists { return nil } newGroup := instance.Redirect(req, resp)