Merge from remote branch
This commit is contained in:
@ -8,14 +8,17 @@ import (
|
||||
"github.com/Dreamacro/clash/common/cache"
|
||||
"github.com/Dreamacro/clash/component/fakeip"
|
||||
"github.com/Dreamacro/clash/component/trie"
|
||||
C "github.com/Dreamacro/clash/constant"
|
||||
"github.com/Dreamacro/clash/context"
|
||||
"github.com/Dreamacro/clash/log"
|
||||
|
||||
D "github.com/miekg/dns"
|
||||
)
|
||||
|
||||
type handler func(ctx *context.DNSContext, r *D.Msg) (*D.Msg, error)
|
||||
type middleware func(next handler) handler
|
||||
type (
|
||||
handler func(ctx *context.DNSContext, r *D.Msg) (*D.Msg, error)
|
||||
middleware func(next handler) handler
|
||||
)
|
||||
|
||||
func withHosts(hosts *trie.DomainTrie) middleware {
|
||||
return func(next handler) handler {
|
||||
@ -105,7 +108,7 @@ func withFakeIP(fakePool *fakeip.Pool) middleware {
|
||||
q := r.Question[0]
|
||||
|
||||
host := strings.TrimRight(q.Name, ".")
|
||||
if fakePool.LookupHost(host) {
|
||||
if fakePool.ShouldSkipped(host) {
|
||||
return next(ctx, r)
|
||||
}
|
||||
|
||||
@ -176,11 +179,11 @@ func NewHandler(resolver *Resolver, mapper *ResolverEnhancer) handler {
|
||||
middlewares = append(middlewares, withHosts(resolver.hosts))
|
||||
}
|
||||
|
||||
if mapper.mode == FAKEIP {
|
||||
if mapper.mode == C.DNSFakeIP {
|
||||
middlewares = append(middlewares, withFakeIP(mapper.fakePool))
|
||||
}
|
||||
|
||||
if mapper.mode != NORMAL {
|
||||
if mapper.mode != C.DNSNormal {
|
||||
middlewares = append(middlewares, withMapping(mapper.mapping))
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user