2019-06-28 12:29:08 +08:00
|
|
|
package dns
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
2020-04-16 18:31:40 +08:00
|
|
|
"fmt"
|
2020-02-14 16:36:20 +08:00
|
|
|
"math/rand"
|
2019-06-28 12:29:08 +08:00
|
|
|
"net"
|
2020-09-28 22:17:10 +08:00
|
|
|
"strings"
|
2019-06-28 12:29:08 +08:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/Dreamacro/clash/common/cache"
|
|
|
|
"github.com/Dreamacro/clash/common/picker"
|
|
|
|
"github.com/Dreamacro/clash/component/fakeip"
|
2020-02-15 21:42:46 +08:00
|
|
|
"github.com/Dreamacro/clash/component/resolver"
|
2020-08-11 10:28:17 +08:00
|
|
|
"github.com/Dreamacro/clash/component/trie"
|
2021-10-18 21:08:27 +08:00
|
|
|
C "github.com/Dreamacro/clash/constant"
|
2019-06-28 12:29:08 +08:00
|
|
|
|
|
|
|
D "github.com/miekg/dns"
|
2019-07-14 19:29:58 +08:00
|
|
|
"golang.org/x/sync/singleflight"
|
2019-06-28 12:29:08 +08:00
|
|
|
)
|
|
|
|
|
2020-02-15 21:42:46 +08:00
|
|
|
type dnsClient interface {
|
2019-06-28 12:29:08 +08:00
|
|
|
Exchange(m *D.Msg) (msg *D.Msg, err error)
|
|
|
|
ExchangeContext(ctx context.Context, m *D.Msg) (msg *D.Msg, err error)
|
|
|
|
}
|
|
|
|
|
|
|
|
type result struct {
|
|
|
|
Msg *D.Msg
|
|
|
|
Error error
|
|
|
|
}
|
|
|
|
|
|
|
|
type Resolver struct {
|
2020-09-28 22:17:10 +08:00
|
|
|
ipv6 bool
|
|
|
|
hosts *trie.DomainTrie
|
|
|
|
main []dnsClient
|
|
|
|
fallback []dnsClient
|
|
|
|
fallbackDomainFilters []fallbackDomainFilter
|
|
|
|
fallbackIPFilters []fallbackIPFilter
|
|
|
|
group singleflight.Group
|
|
|
|
lruCache *cache.LruCache
|
2021-05-19 11:17:35 +08:00
|
|
|
policy *trie.DomainTrie
|
2019-06-28 12:29:08 +08:00
|
|
|
}
|
|
|
|
|
2022-08-13 13:07:35 +08:00
|
|
|
// LookupIP request with TypeA and TypeAAAA, priority return TypeA
|
|
|
|
func (r *Resolver) LookupIP(ctx context.Context, host string) (ip []net.IP, err error) {
|
|
|
|
ctx, cancel := context.WithCancel(ctx)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
ch := make(chan []net.IP, 1)
|
|
|
|
|
2019-06-28 12:29:08 +08:00
|
|
|
go func() {
|
2019-06-29 00:58:59 +08:00
|
|
|
defer close(ch)
|
2022-08-13 13:07:35 +08:00
|
|
|
ip, err := r.lookupIP(ctx, host, D.TypeAAAA)
|
2019-06-28 12:29:08 +08:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
ch <- ip
|
|
|
|
}()
|
|
|
|
|
2022-08-13 13:07:35 +08:00
|
|
|
ip, err = r.lookupIP(ctx, host, D.TypeA)
|
2019-06-28 12:29:08 +08:00
|
|
|
if err == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-06-29 00:58:59 +08:00
|
|
|
ip, open := <-ch
|
|
|
|
if !open {
|
2020-02-15 21:42:46 +08:00
|
|
|
return nil, resolver.ErrIPNotFound
|
2019-06-28 12:29:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return ip, nil
|
|
|
|
}
|
|
|
|
|
2022-08-13 13:07:35 +08:00
|
|
|
// ResolveIP request with TypeA and TypeAAAA, priority return TypeA
|
|
|
|
func (r *Resolver) ResolveIP(host string) (ip net.IP, err error) {
|
|
|
|
ips, err := r.LookupIP(context.Background(), host)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
} else if len(ips) == 0 {
|
|
|
|
return nil, fmt.Errorf("%w: %s", resolver.ErrIPNotFound, host)
|
|
|
|
}
|
|
|
|
return ips[rand.Intn(len(ips))], nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// LookupIPv4 request with TypeA
|
|
|
|
func (r *Resolver) LookupIPv4(ctx context.Context, host string) ([]net.IP, error) {
|
|
|
|
return r.lookupIP(ctx, host, D.TypeA)
|
|
|
|
}
|
|
|
|
|
2019-06-28 12:29:08 +08:00
|
|
|
// ResolveIPv4 request with TypeA
|
|
|
|
func (r *Resolver) ResolveIPv4(host string) (ip net.IP, err error) {
|
2022-08-13 13:07:35 +08:00
|
|
|
ips, err := r.lookupIP(context.Background(), host, D.TypeA)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
} else if len(ips) == 0 {
|
|
|
|
return nil, fmt.Errorf("%w: %s", resolver.ErrIPNotFound, host)
|
|
|
|
}
|
|
|
|
return ips[rand.Intn(len(ips))], nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// LookupIPv6 request with TypeAAAA
|
|
|
|
func (r *Resolver) LookupIPv6(ctx context.Context, host string) ([]net.IP, error) {
|
|
|
|
return r.lookupIP(ctx, host, D.TypeAAAA)
|
2019-09-11 17:00:55 +08:00
|
|
|
}
|
2019-06-28 12:29:08 +08:00
|
|
|
|
2019-09-11 17:00:55 +08:00
|
|
|
// ResolveIPv6 request with TypeAAAA
|
|
|
|
func (r *Resolver) ResolveIPv6(host string) (ip net.IP, err error) {
|
2022-08-13 13:07:35 +08:00
|
|
|
ips, err := r.lookupIP(context.Background(), host, D.TypeAAAA)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
} else if len(ips) == 0 {
|
|
|
|
return nil, fmt.Errorf("%w: %s", resolver.ErrIPNotFound, host)
|
|
|
|
}
|
|
|
|
return ips[rand.Intn(len(ips))], nil
|
2019-06-28 12:29:08 +08:00
|
|
|
}
|
|
|
|
|
2020-09-28 22:17:10 +08:00
|
|
|
func (r *Resolver) shouldIPFallback(ip net.IP) bool {
|
|
|
|
for _, filter := range r.fallbackIPFilters {
|
2019-09-15 13:36:45 +08:00
|
|
|
if filter.Match(ip) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-06-28 12:29:08 +08:00
|
|
|
// Exchange a batch of dns request, and it use cache
|
|
|
|
func (r *Resolver) Exchange(m *D.Msg) (msg *D.Msg, err error) {
|
2021-09-06 23:07:34 +08:00
|
|
|
return r.ExchangeContext(context.Background(), m)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ExchangeContext a batch of dns request with context.Context, and it use cache
|
|
|
|
func (r *Resolver) ExchangeContext(ctx context.Context, m *D.Msg) (msg *D.Msg, err error) {
|
2019-06-28 12:29:08 +08:00
|
|
|
if len(m.Question) == 0 {
|
|
|
|
return nil, errors.New("should have one question at least")
|
|
|
|
}
|
|
|
|
|
|
|
|
q := m.Question[0]
|
2020-05-07 15:10:14 +08:00
|
|
|
cache, expireTime, hit := r.lruCache.GetWithExpire(q.String())
|
|
|
|
if hit {
|
|
|
|
now := time.Now()
|
2019-06-28 12:29:08 +08:00
|
|
|
msg = cache.(*D.Msg).Copy()
|
2020-05-07 15:10:14 +08:00
|
|
|
if expireTime.Before(now) {
|
|
|
|
setMsgTTL(msg, uint32(1)) // Continue fetch
|
2021-09-06 23:07:34 +08:00
|
|
|
go r.exchangeWithoutCache(ctx, m)
|
2020-05-07 15:10:14 +08:00
|
|
|
} else {
|
2020-08-25 22:19:59 +08:00
|
|
|
setMsgTTL(msg, uint32(time.Until(expireTime).Seconds()))
|
2020-05-07 15:10:14 +08:00
|
|
|
}
|
2019-06-28 12:29:08 +08:00
|
|
|
return
|
|
|
|
}
|
2021-09-06 23:07:34 +08:00
|
|
|
return r.exchangeWithoutCache(ctx, m)
|
2020-05-07 15:10:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// ExchangeWithoutCache a batch of dns request, and it do NOT GET from cache
|
2021-09-06 23:07:34 +08:00
|
|
|
func (r *Resolver) exchangeWithoutCache(ctx context.Context, m *D.Msg) (msg *D.Msg, err error) {
|
2020-05-07 15:10:14 +08:00
|
|
|
q := m.Question[0]
|
|
|
|
|
2022-03-16 12:10:13 +08:00
|
|
|
ret, err, shared := r.group.Do(q.String(), func() (result any, err error) {
|
2020-07-20 21:16:36 +08:00
|
|
|
defer func() {
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
msg := result.(*D.Msg)
|
|
|
|
|
|
|
|
putMsgToCache(r.lruCache, q.String(), msg)
|
|
|
|
}()
|
|
|
|
|
2020-07-17 17:34:40 +08:00
|
|
|
isIPReq := isIPRequest(q)
|
|
|
|
if isIPReq {
|
2021-09-06 23:07:34 +08:00
|
|
|
return r.ipExchange(ctx, m)
|
2019-06-28 12:29:08 +08:00
|
|
|
}
|
|
|
|
|
2021-05-19 11:17:35 +08:00
|
|
|
if matched := r.matchPolicy(m); len(matched) != 0 {
|
2021-09-06 23:07:34 +08:00
|
|
|
return r.batchExchange(ctx, matched, m)
|
2021-05-19 11:17:35 +08:00
|
|
|
}
|
2021-09-06 23:07:34 +08:00
|
|
|
return r.batchExchange(ctx, r.main, m)
|
2019-07-14 19:29:58 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
if err == nil {
|
|
|
|
msg = ret.(*D.Msg)
|
2020-03-24 10:13:53 +08:00
|
|
|
if shared {
|
|
|
|
msg = msg.Copy()
|
|
|
|
}
|
2019-06-28 12:29:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-09-06 23:07:34 +08:00
|
|
|
func (r *Resolver) batchExchange(ctx context.Context, clients []dnsClient, m *D.Msg) (msg *D.Msg, err error) {
|
|
|
|
fast, ctx := picker.WithTimeout(ctx, resolver.DefaultDNSTimeout)
|
2019-08-02 09:22:09 +08:00
|
|
|
for _, client := range clients {
|
|
|
|
r := client
|
2022-03-16 12:10:13 +08:00
|
|
|
fast.Go(func() (any, error) {
|
2020-02-25 21:51:48 +08:00
|
|
|
m, err := r.ExchangeContext(ctx, m)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
2020-03-08 13:00:42 +08:00
|
|
|
} else if m.Rcode == D.RcodeServerFailure || m.Rcode == D.RcodeRefused {
|
2020-02-25 21:51:48 +08:00
|
|
|
return nil, errors.New("server failure")
|
|
|
|
}
|
|
|
|
return m, nil
|
2019-07-02 19:18:03 +08:00
|
|
|
})
|
2019-06-28 12:29:08 +08:00
|
|
|
}
|
|
|
|
|
2020-02-14 16:36:20 +08:00
|
|
|
elm := fast.Wait()
|
2019-07-02 19:18:03 +08:00
|
|
|
if elm == nil {
|
2020-08-25 22:19:59 +08:00
|
|
|
err := errors.New("all DNS requests failed")
|
2020-04-16 18:31:40 +08:00
|
|
|
if fErr := fast.Error(); fErr != nil {
|
|
|
|
err = fmt.Errorf("%w, first error: %s", err, fErr.Error())
|
|
|
|
}
|
|
|
|
return nil, err
|
2019-06-28 12:29:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
msg = elm.(*D.Msg)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-05-19 11:17:35 +08:00
|
|
|
func (r *Resolver) matchPolicy(m *D.Msg) []dnsClient {
|
|
|
|
if r.policy == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
domain := r.msgToDomain(m)
|
|
|
|
if domain == "" {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
record := r.policy.Search(domain)
|
|
|
|
if record == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return record.Data.([]dnsClient)
|
|
|
|
}
|
|
|
|
|
2020-09-28 22:17:10 +08:00
|
|
|
func (r *Resolver) shouldOnlyQueryFallback(m *D.Msg) bool {
|
|
|
|
if r.fallback == nil || len(r.fallbackDomainFilters) == 0 {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
domain := r.msgToDomain(m)
|
|
|
|
|
|
|
|
if domain == "" {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, df := range r.fallbackDomainFilters {
|
|
|
|
if df.Match(domain) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2021-09-06 23:07:34 +08:00
|
|
|
func (r *Resolver) ipExchange(ctx context.Context, m *D.Msg) (msg *D.Msg, err error) {
|
2021-05-19 11:17:35 +08:00
|
|
|
if matched := r.matchPolicy(m); len(matched) != 0 {
|
2021-09-06 23:07:34 +08:00
|
|
|
res := <-r.asyncExchange(ctx, matched, m)
|
2021-05-19 11:17:35 +08:00
|
|
|
return res.Msg, res.Error
|
|
|
|
}
|
|
|
|
|
2020-09-28 22:17:10 +08:00
|
|
|
onlyFallback := r.shouldOnlyQueryFallback(m)
|
|
|
|
|
|
|
|
if onlyFallback {
|
2021-09-06 23:07:34 +08:00
|
|
|
res := <-r.asyncExchange(ctx, r.fallback, m)
|
2020-09-28 22:17:10 +08:00
|
|
|
return res.Msg, res.Error
|
|
|
|
}
|
|
|
|
|
2021-09-06 23:07:34 +08:00
|
|
|
msgCh := r.asyncExchange(ctx, r.main, m)
|
2020-09-28 22:17:10 +08:00
|
|
|
|
|
|
|
if r.fallback == nil { // directly return if no fallback servers are available
|
2019-06-28 12:29:08 +08:00
|
|
|
res := <-msgCh
|
|
|
|
msg, err = res.Msg, res.Error
|
|
|
|
return
|
|
|
|
}
|
2020-09-28 22:17:10 +08:00
|
|
|
|
2021-09-06 23:07:34 +08:00
|
|
|
fallbackMsg := r.asyncExchange(ctx, r.fallback, m)
|
2019-06-28 12:29:08 +08:00
|
|
|
res := <-msgCh
|
|
|
|
if res.Error == nil {
|
2021-01-23 14:49:46 +08:00
|
|
|
if ips := msgToIP(res.Msg); len(ips) != 0 {
|
2020-09-28 22:17:10 +08:00
|
|
|
if !r.shouldIPFallback(ips[0]) {
|
|
|
|
msg = res.Msg // no need to wait for fallback result
|
2020-03-08 13:00:42 +08:00
|
|
|
err = res.Error
|
2019-06-28 12:29:08 +08:00
|
|
|
return msg, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
res = <-fallbackMsg
|
|
|
|
msg, err = res.Msg, res.Error
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-08-13 13:07:35 +08:00
|
|
|
func (r *Resolver) lookupIP(ctx context.Context, host string, dnsType uint16) ([]net.IP, error) {
|
|
|
|
ip := net.ParseIP(host)
|
2019-09-27 10:33:37 +08:00
|
|
|
if ip != nil {
|
2022-08-13 13:07:35 +08:00
|
|
|
ip4 := ip.To4()
|
|
|
|
isIPv4 := ip4 != nil
|
2019-09-27 15:26:07 +08:00
|
|
|
if dnsType == D.TypeAAAA && !isIPv4 {
|
2022-08-13 13:07:35 +08:00
|
|
|
return []net.IP{ip}, nil
|
2019-09-27 15:26:07 +08:00
|
|
|
} else if dnsType == D.TypeA && isIPv4 {
|
2022-08-13 13:07:35 +08:00
|
|
|
return []net.IP{ip4}, nil
|
2020-02-17 20:11:46 +08:00
|
|
|
} else {
|
|
|
|
return nil, resolver.ErrIPVersion
|
2019-09-11 17:00:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-28 12:29:08 +08:00
|
|
|
query := &D.Msg{}
|
|
|
|
query.SetQuestion(D.Fqdn(host), dnsType)
|
|
|
|
|
|
|
|
msg, err := r.Exchange(query)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-01-23 14:49:46 +08:00
|
|
|
ips := msgToIP(msg)
|
2022-08-13 13:07:35 +08:00
|
|
|
if len(ips) == 0 {
|
2020-02-15 21:42:46 +08:00
|
|
|
return nil, resolver.ErrIPNotFound
|
2019-06-28 12:29:08 +08:00
|
|
|
}
|
2022-08-13 13:07:35 +08:00
|
|
|
return ips, nil
|
2019-06-28 12:29:08 +08:00
|
|
|
}
|
|
|
|
|
2020-09-28 22:17:10 +08:00
|
|
|
func (r *Resolver) msgToDomain(msg *D.Msg) string {
|
|
|
|
if len(msg.Question) > 0 {
|
|
|
|
return strings.TrimRight(msg.Question[0].Name, ".")
|
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2021-09-06 23:07:34 +08:00
|
|
|
func (r *Resolver) asyncExchange(ctx context.Context, client []dnsClient, msg *D.Msg) <-chan *result {
|
2020-03-13 00:11:54 +08:00
|
|
|
ch := make(chan *result, 1)
|
2019-06-28 12:29:08 +08:00
|
|
|
go func() {
|
2021-09-06 23:07:34 +08:00
|
|
|
res, err := r.batchExchange(ctx, client, msg)
|
2019-06-28 12:29:08 +08:00
|
|
|
ch <- &result{Msg: res, Error: err}
|
|
|
|
}()
|
|
|
|
return ch
|
|
|
|
}
|
|
|
|
|
|
|
|
type NameServer struct {
|
2021-10-05 13:31:19 +08:00
|
|
|
Net string
|
|
|
|
Addr string
|
|
|
|
Interface string
|
2019-06-28 12:29:08 +08:00
|
|
|
}
|
|
|
|
|
2019-09-15 13:36:45 +08:00
|
|
|
type FallbackFilter struct {
|
2021-08-25 15:15:13 +08:00
|
|
|
GeoIP bool
|
|
|
|
GeoIPCode string
|
|
|
|
IPCIDR []*net.IPNet
|
|
|
|
Domain []string
|
2019-09-15 13:36:45 +08:00
|
|
|
}
|
|
|
|
|
2019-06-28 12:29:08 +08:00
|
|
|
type Config struct {
|
|
|
|
Main, Fallback []NameServer
|
2020-02-15 21:42:46 +08:00
|
|
|
Default []NameServer
|
2019-06-28 12:29:08 +08:00
|
|
|
IPv6 bool
|
2021-10-18 21:08:27 +08:00
|
|
|
EnhancedMode C.DNSMode
|
2019-09-15 13:36:45 +08:00
|
|
|
FallbackFilter FallbackFilter
|
2019-06-28 12:29:08 +08:00
|
|
|
Pool *fakeip.Pool
|
2020-08-11 10:28:17 +08:00
|
|
|
Hosts *trie.DomainTrie
|
2021-05-19 11:17:35 +08:00
|
|
|
Policy map[string]NameServer
|
2019-06-28 12:29:08 +08:00
|
|
|
}
|
|
|
|
|
2020-09-17 10:48:42 +08:00
|
|
|
func NewResolver(config Config) *Resolver {
|
2020-02-15 21:42:46 +08:00
|
|
|
defaultResolver := &Resolver{
|
2020-05-07 15:10:14 +08:00
|
|
|
main: transform(config.Default, nil),
|
|
|
|
lruCache: cache.NewLRUCache(cache.WithSize(4096), cache.WithStale(true)),
|
2020-02-15 21:42:46 +08:00
|
|
|
}
|
|
|
|
|
2019-06-28 12:29:08 +08:00
|
|
|
r := &Resolver{
|
2020-05-07 15:10:14 +08:00
|
|
|
ipv6: config.IPv6,
|
|
|
|
main: transform(config.Main, defaultResolver),
|
|
|
|
lruCache: cache.NewLRUCache(cache.WithSize(4096), cache.WithStale(true)),
|
2020-08-11 10:28:17 +08:00
|
|
|
hosts: config.Hosts,
|
2019-06-28 12:29:08 +08:00
|
|
|
}
|
2019-09-15 13:36:45 +08:00
|
|
|
|
2019-06-28 12:29:08 +08:00
|
|
|
if len(config.Fallback) != 0 {
|
2020-02-15 21:42:46 +08:00
|
|
|
r.fallback = transform(config.Fallback, defaultResolver)
|
2019-06-28 12:29:08 +08:00
|
|
|
}
|
2019-09-15 13:36:45 +08:00
|
|
|
|
2021-05-19 11:17:35 +08:00
|
|
|
if len(config.Policy) != 0 {
|
|
|
|
r.policy = trie.New()
|
|
|
|
for domain, nameserver := range config.Policy {
|
|
|
|
r.policy.Insert(domain, transform([]NameServer{nameserver}, defaultResolver))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-28 22:17:10 +08:00
|
|
|
fallbackIPFilters := []fallbackIPFilter{}
|
2019-09-15 13:36:45 +08:00
|
|
|
if config.FallbackFilter.GeoIP {
|
2021-08-25 15:15:13 +08:00
|
|
|
fallbackIPFilters = append(fallbackIPFilters, &geoipFilter{
|
|
|
|
code: config.FallbackFilter.GeoIPCode,
|
|
|
|
})
|
2019-09-15 13:36:45 +08:00
|
|
|
}
|
|
|
|
for _, ipnet := range config.FallbackFilter.IPCIDR {
|
2020-09-28 22:17:10 +08:00
|
|
|
fallbackIPFilters = append(fallbackIPFilters, &ipnetFilter{ipnet: ipnet})
|
|
|
|
}
|
|
|
|
r.fallbackIPFilters = fallbackIPFilters
|
|
|
|
|
|
|
|
if len(config.FallbackFilter.Domain) != 0 {
|
|
|
|
fallbackDomainFilters := []fallbackDomainFilter{NewDomainFilter(config.FallbackFilter.Domain)}
|
|
|
|
r.fallbackDomainFilters = fallbackDomainFilters
|
2019-09-15 13:36:45 +08:00
|
|
|
}
|
|
|
|
|
2019-06-28 12:29:08 +08:00
|
|
|
return r
|
|
|
|
}
|