鏡像自
https://github.com/XTLS/Xray-core.git
已同步 2025-07-03 00:24:15 +00:00
feat: add queryStrategy option for DNS
這個提交存在於:
父節點
41d3f31447
當前提交
8382b29922
共有 16 個檔案被更改,包括 419 行新增 和 267 行删除
|
@ -63,30 +63,27 @@ func (d *DefaultSystemDialer) lookupIP(domain string, strategy DomainStrategy, l
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
var option = dns.IPOption{
|
||||
IPv4Enable: true,
|
||||
IPv6Enable: true,
|
||||
FakeEnable: false,
|
||||
if c, ok := d.dns.(dns.ClientWithIPOption); ok {
|
||||
c.SetFakeDNSOption(false) // Skip FakeDNS
|
||||
} else {
|
||||
newError("DNS client doesn't implement ClientWithIPOption")
|
||||
}
|
||||
|
||||
var lookupFunc func(string) ([]net.IP, error) = d.dns.LookupIP
|
||||
switch {
|
||||
case strategy == DomainStrategy_USE_IP4 || (localAddr != nil && localAddr.Family().IsIPv4()):
|
||||
option = dns.IPOption{
|
||||
IPv4Enable: true,
|
||||
IPv6Enable: false,
|
||||
FakeEnable: false,
|
||||
if lookupIPv4, ok := d.dns.(dns.IPv4Lookup); ok {
|
||||
lookupFunc = lookupIPv4.LookupIPv4
|
||||
}
|
||||
case strategy == DomainStrategy_USE_IP6 || (localAddr != nil && localAddr.Family().IsIPv6()):
|
||||
option = dns.IPOption{
|
||||
IPv4Enable: false,
|
||||
IPv6Enable: true,
|
||||
FakeEnable: false,
|
||||
if lookupIPv6, ok := d.dns.(dns.IPv6Lookup); ok {
|
||||
lookupFunc = lookupIPv6.LookupIPv6
|
||||
}
|
||||
case strategy == DomainStrategy_AS_IS:
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return d.dns.LookupIP(domain, option)
|
||||
return lookupFunc(domain)
|
||||
}
|
||||
|
||||
func (d *DefaultSystemDialer) doLookupIP(ctx context.Context, dst net.Destination, sockopt *SocketConfig) bool {
|
||||
|
|
載入中…
新增表格
新增連結
新增問題並參考