mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 09:18:34 +00:00
DNS: Add allowUnexpectedIPs
for DnsServerObject (#4497)
Closes https://github.com/XTLS/Xray-core/issues/4424
This commit is contained in:
parent
335845a9b2
commit
6a211a0bb9
4 changed files with 55 additions and 34 deletions
|
@ -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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue