mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-04 11:18:40 +00:00
Refine DNS strategies
This commit is contained in:
parent
f4a048aa0c
commit
726a722019
21 changed files with 255 additions and 208 deletions
|
@ -22,6 +22,9 @@ type Client interface {
|
|||
|
||||
// LookupIP returns IP address for the given domain. IPs may contain IPv4 and/or IPv6 addresses.
|
||||
LookupIP(domain string) ([]net.IP, error)
|
||||
|
||||
// LookupOptions query IP address for domain with IPOption.
|
||||
LookupOptions(domain string, opt IPOption) ([]net.IP, error)
|
||||
}
|
||||
|
||||
// IPv4Lookup is an optional feature for querying IPv4 addresses only.
|
||||
|
@ -38,20 +41,6 @@ type IPv6Lookup interface {
|
|||
LookupIPv6(domain string) ([]net.IP, error)
|
||||
}
|
||||
|
||||
// ClientWithIPOption is an optional feature for querying DNS information.
|
||||
//
|
||||
// xray:api:beta
|
||||
type ClientWithIPOption interface {
|
||||
// GetIPOption returns IPOption for the DNS client.
|
||||
GetIPOption() *IPOption
|
||||
|
||||
// SetQueryOption sets IPv4Enable and IPv6Enable for the DNS client.
|
||||
SetQueryOption(isIPv4Enable, isIPv6Enable bool)
|
||||
|
||||
// SetFakeDNSOption sets FakeEnable option for DNS client.
|
||||
SetFakeDNSOption(isFakeEnable bool)
|
||||
}
|
||||
|
||||
// ClientType returns the type of Client interface. Can be used for implementing common.HasType.
|
||||
//
|
||||
// xray:api:beta
|
||||
|
@ -78,3 +67,11 @@ func RCodeFromError(err error) uint16 {
|
|||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var (
|
||||
LookupIPv4 = IPOption{IPv4Enable: true}
|
||||
LookupIPv6 = IPOption{IPv6Enable: true}
|
||||
LookupIP = IPOption{IPv4Enable: true, IPv6Enable: true}
|
||||
LookupFake = IPOption{FakeEnable: true}
|
||||
LookupAll = IPOption{true, true, true}
|
||||
)
|
||||
|
|
|
@ -38,6 +38,11 @@ func (*Client) LookupIP(host string) ([]net.IP, error) {
|
|||
return parsedIPs, nil
|
||||
}
|
||||
|
||||
// LookupOptions implements Client.
|
||||
func (c *Client) LookupOptions(host string, _ dns.IPOption) ([]net.IP, error) {
|
||||
return c.LookupIP(host)
|
||||
}
|
||||
|
||||
// LookupIPv4 implements IPv4Lookup.
|
||||
func (c *Client) LookupIPv4(host string) ([]net.IP, error) {
|
||||
ips, err := c.LookupIP(host)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue