mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-06-16 05:17:16 +03:00
DNS: Add allowUnexpectedIPs
for DnsServerObject (#4497)
Closes https://github.com/XTLS/Xray-core/issues/4424
This commit is contained in:
@ -25,11 +25,12 @@ type Server interface {
|
||||
|
||||
// Client is the interface for DNS client.
|
||||
type Client struct {
|
||||
server Server
|
||||
clientIP net.IP
|
||||
skipFallback bool
|
||||
domains []string
|
||||
expectIPs []*router.GeoIPMatcher
|
||||
server Server
|
||||
clientIP net.IP
|
||||
skipFallback bool
|
||||
domains []string
|
||||
expectIPs []*router.GeoIPMatcher
|
||||
allowUnexpectedIPs bool
|
||||
}
|
||||
|
||||
var errExpectedIPNonMatch = errors.New("expectIPs not match")
|
||||
@ -166,6 +167,7 @@ func NewClient(
|
||||
client.skipFallback = ns.SkipFallback
|
||||
client.domains = rules
|
||||
client.expectIPs = matchers
|
||||
client.allowUnexpectedIPs = ns.AllowUnexpectedIPs
|
||||
return nil
|
||||
})
|
||||
return client, err
|
||||
@ -203,6 +205,9 @@ func (c *Client) MatchExpectedIPs(domain string, ips []net.IP) ([]net.IP, error)
|
||||
}
|
||||
}
|
||||
if len(newIps) == 0 {
|
||||
if c.allowUnexpectedIPs {
|
||||
return ips, nil
|
||||
}
|
||||
return nil, errExpectedIPNonMatch
|
||||
}
|
||||
errors.LogDebug(context.Background(), "domain ", domain, " expectIPs ", newIps, " matched at server ", c.Name())
|
||||
|
Reference in New Issue
Block a user