Skip to content

Commit

Permalink
feat: fix panic in another way
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf-joe committed Dec 22, 2022
1 parent b1bcc3d commit d81a033
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion inbound/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 5 additions & 4 deletions redirector/redirector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d81a033

Please sign in to comment.