Browse Source

fix a bug

pull/15/head
Jason 5 years ago
parent
commit
182e1695ef
  1. 2
      component/fakedns/middleware.go
  2. 8
      component/fakedns/resolver.go

2
component/fakedns/middleware.go

@ -113,7 +113,7 @@ func hostResolve(hosts *T.Trie, r *D.Msg) *D.Msg {
return msg
}
func newHandler(hosts *T.Trie, pool *F.Pool, backendDNS []string) D.HandlerFunc {
func newHandler(hosts *T.Trie, pool *F.Pool, backendDNS []string) handler {
return func(w D.ResponseWriter, r *D.Msg) {
msg := resolve(hosts, pool, backendDNS, r)
w.WriteMsg(msg)

8
component/fakedns/resolver.go

@ -22,11 +22,13 @@ const (
dnsFakeIPRange = "198.18.0.0/15"
)
type handler = D.HandlerFunc
type Resolver struct {
b []string
h handler
p *F.Pool
t *T.Trie
h D.HandlerFunc
*D.Server
ServeAddr string
@ -86,7 +88,7 @@ func (r *Resolver) Resolve(request []byte) ([]byte, error) {
return nil, errors.New("cannot handle dns query: invalid question length")
}
msg := resolve(r.h, r.p, r.b, req)
msg := resolve(r.t, r.p, r.b, req)
if msg == nil {
return nil, errors.New("cannot resolve dns query: msg is nil")
}
@ -126,9 +128,9 @@ func NewResolver(a, h, b string) (*Resolver, error) {
handler := newHandler(tree, pool, backendDNS)
return &Resolver{
b: backendDNS,
h: handler,
p: pool,
t: tree,
h: handler,
ServeAddr: a,
}, nil
}

Loading…
Cancel
Save