mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-29 16:58:34 +00:00
Refine DNS Options
This commit is contained in:
parent
f20c445974
commit
217844cc37
10 changed files with 82 additions and 55 deletions
|
@ -199,18 +199,16 @@ func (h *Handler) handleIPQuery(id uint16, qType dnsmessage.Type, domain string,
|
|||
var err error
|
||||
|
||||
var ttl uint32 = 600
|
||||
var opt = dns.LookupIP
|
||||
var opt dns.Option
|
||||
|
||||
switch qType {
|
||||
case dnsmessage.TypeA:
|
||||
opt = dns.LookupIPv4
|
||||
opt = dns.LookupIPv4Only
|
||||
case dnsmessage.TypeAAAA:
|
||||
opt = dns.LookupIPv6
|
||||
opt = dns.LookupIPv6Only
|
||||
}
|
||||
|
||||
opt.FakeEnable = true
|
||||
|
||||
ips, err = h.client.LookupOptions(domain, opt)
|
||||
ips, err = h.client.LookupOptions(domain, opt, dns.LookupFake)
|
||||
rcode := dns.RCodeFromError(err)
|
||||
if rcode == 0 && len(ips) == 0 && err != dns.ErrEmptyResponse {
|
||||
newError("ip query").Base(err).WriteToLog()
|
||||
|
|
|
@ -59,15 +59,14 @@ func (h *Handler) policy() policy.Session {
|
|||
}
|
||||
|
||||
func (h *Handler) resolveIP(ctx context.Context, domain string, localAddr net.Address) net.Address {
|
||||
var opt = dns.LookupIP
|
||||
var opt dns.Option
|
||||
if h.config.DomainStrategy == Config_USE_IP4 || (localAddr != nil && localAddr.Family().IsIPv4()) {
|
||||
opt = dns.LookupIPv4
|
||||
opt = dns.LookupIPv4Only
|
||||
} else if h.config.DomainStrategy == Config_USE_IP6 || (localAddr != nil && localAddr.Family().IsIPv6()) {
|
||||
opt = dns.LookupIPv6
|
||||
opt = dns.LookupIPv6Only
|
||||
}
|
||||
opt.FakeEnable = true
|
||||
|
||||
ips, err := h.dns.LookupOptions(domain, opt)
|
||||
ips, err := h.dns.LookupOptions(domain, opt, dns.LookupNoFake)
|
||||
if err != nil {
|
||||
newError("failed to get IP address for domain ", domain).Base(err).WriteToLog(session.ExportIDToError(ctx))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue