0
mirror of https://github.com/XTLS/Xray-core.git synced 2025-06-19 14:48:03 +03:00

Feat: add disableFallback & skipFallback option for DNS client (#489)

This commit is contained in:
秋のかえで
2021-04-10 00:07:08 +08:00
committed by GitHub
parent 70b63e21a5
commit 6e902b24ae
6 changed files with 191 additions and 145 deletions

View File

@ -25,10 +25,11 @@ type Server interface {
// Client is the interface for DNS client.
type Client struct {
server Server
clientIP net.IP
domains []string
expectIPs []*router.GeoIPMatcher
server Server
clientIP net.IP
skipFallback bool
domains []string
expectIPs []*router.GeoIPMatcher
}
var errExpectedIPNonMatch = errors.New("expectIPs not match")
@ -65,6 +66,7 @@ func NewServer(dest net.Destination, dispatcher routing.Dispatcher) (Server, err
// NewClient creates a DNS client managing a name server with client IP, domain rules and expected IPs.
func NewClient(ctx context.Context, ns *NameServer, clientIP net.IP, container router.GeoIPMatcherContainer, matcherInfos *[]DomainMatcherInfo, updateDomainRule func(strmatcher.Matcher, int, []DomainMatcherInfo) error) (*Client, error) {
client := &Client{}
err := core.RequireFeatures(ctx, func(dispatcher routing.Dispatcher) error {
// Create a new server for each client for now
server, err := NewServer(ns.Address.AsDestination(), dispatcher)