mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-13 20:44:12 +08:00
rename
This commit is contained in:
parent
a81a8fee84
commit
67d0a2df71
@ -28,7 +28,7 @@ type DNS struct {
|
|||||||
ctx context.Context
|
ctx context.Context
|
||||||
domainMatcher strmatcher.IndexMatcher
|
domainMatcher strmatcher.IndexMatcher
|
||||||
matcherInfos []*DomainMatcherInfo
|
matcherInfos []*DomainMatcherInfo
|
||||||
useSystem bool
|
checkSystem bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// DomainMatcherInfo contains information attached to index returned by Server.domainMatcher
|
// DomainMatcherInfo contains information attached to index returned by Server.domainMatcher
|
||||||
@ -48,7 +48,7 @@ func New(ctx context.Context, config *Config) (*DNS, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var ipOption dns.IPOption
|
var ipOption dns.IPOption
|
||||||
useSystem := false
|
checkSystem := false
|
||||||
switch config.QueryStrategy {
|
switch config.QueryStrategy {
|
||||||
case QueryStrategy_USE_IP:
|
case QueryStrategy_USE_IP:
|
||||||
ipOption = dns.IPOption{
|
ipOption = dns.IPOption{
|
||||||
@ -62,7 +62,7 @@ func New(ctx context.Context, config *Config) (*DNS, error) {
|
|||||||
IPv6Enable: true,
|
IPv6Enable: true,
|
||||||
FakeEnable: false,
|
FakeEnable: false,
|
||||||
}
|
}
|
||||||
useSystem = true
|
checkSystem = true
|
||||||
case QueryStrategy_USE_IP4:
|
case QueryStrategy_USE_IP4:
|
||||||
ipOption = dns.IPOption{
|
ipOption = dns.IPOption{
|
||||||
IPv4Enable: true,
|
IPv4Enable: true,
|
||||||
@ -149,7 +149,7 @@ func New(ctx context.Context, config *Config) (*DNS, error) {
|
|||||||
matcherInfos: matcherInfos,
|
matcherInfos: matcherInfos,
|
||||||
disableFallback: config.DisableFallback,
|
disableFallback: config.DisableFallback,
|
||||||
disableFallbackIfMatch: config.DisableFallbackIfMatch,
|
disableFallbackIfMatch: config.DisableFallbackIfMatch,
|
||||||
useSystem: useSystem,
|
checkSystem: checkSystem,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ func (s *DNS) LookupIP(domain string, option dns.IPOption) ([]net.IP, uint32, er
|
|||||||
return nil, 0, errors.New("empty domain name")
|
return nil, 0, errors.New("empty domain name")
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.useSystem {
|
if s.checkSystem {
|
||||||
supportIPv4, supportIPv6 := checkSystemNetwork()
|
supportIPv4, supportIPv6 := checkSystemNetwork()
|
||||||
option.IPv4Enable = option.IPv4Enable && supportIPv4
|
option.IPv4Enable = option.IPv4Enable && supportIPv4
|
||||||
option.IPv6Enable = option.IPv6Enable && supportIPv6
|
option.IPv6Enable = option.IPv6Enable && supportIPv6
|
||||||
|
@ -37,7 +37,7 @@ type Client struct {
|
|||||||
timeoutMs time.Duration
|
timeoutMs time.Duration
|
||||||
finalQuery bool
|
finalQuery bool
|
||||||
ipOption *dns.IPOption
|
ipOption *dns.IPOption
|
||||||
useSystem bool
|
checkSystem bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewServer creates a name server object according to the network destination url.
|
// NewServer creates a name server object according to the network destination url.
|
||||||
@ -187,7 +187,7 @@ func NewClient(
|
|||||||
timeoutMs = time.Duration(ns.TimeoutMs) * time.Millisecond
|
timeoutMs = time.Duration(ns.TimeoutMs) * time.Millisecond
|
||||||
}
|
}
|
||||||
|
|
||||||
useSystem := ns.QueryStrategy == QueryStrategy_USE_SYS
|
checkSystem := ns.QueryStrategy == QueryStrategy_USE_SYS
|
||||||
|
|
||||||
client.server = server
|
client.server = server
|
||||||
client.skipFallback = ns.SkipFallback
|
client.skipFallback = ns.SkipFallback
|
||||||
@ -200,7 +200,7 @@ func NewClient(
|
|||||||
client.timeoutMs = timeoutMs
|
client.timeoutMs = timeoutMs
|
||||||
client.finalQuery = ns.FinalQuery
|
client.finalQuery = ns.FinalQuery
|
||||||
client.ipOption = &ipOption
|
client.ipOption = &ipOption
|
||||||
client.useSystem = useSystem
|
client.checkSystem = checkSystem
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
return client, err
|
return client, err
|
||||||
@ -217,7 +217,7 @@ func (c *Client) IsFinalQuery() bool {
|
|||||||
|
|
||||||
// QueryIP sends DNS query to the name server with the client's IP.
|
// QueryIP sends DNS query to the name server with the client's IP.
|
||||||
func (c *Client) QueryIP(ctx context.Context, domain string, option dns.IPOption) ([]net.IP, uint32, error) {
|
func (c *Client) QueryIP(ctx context.Context, domain string, option dns.IPOption) ([]net.IP, uint32, error) {
|
||||||
if c.useSystem {
|
if c.checkSystem {
|
||||||
supportIPv4, supportIPv6 := checkSystemNetwork()
|
supportIPv4, supportIPv6 := checkSystemNetwork()
|
||||||
option.IPv4Enable = option.IPv4Enable && supportIPv4
|
option.IPv4Enable = option.IPv4Enable && supportIPv4
|
||||||
option.IPv6Enable = option.IPv6Enable && supportIPv6
|
option.IPv6Enable = option.IPv6Enable && supportIPv6
|
||||||
|
Loading…
x
Reference in New Issue
Block a user