mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-04 06:13:35 +03:00
Fix queryStrategy 4+6
This commit is contained in:
parent
4a4eaa24fd
commit
d2f10dbc6a
1 changed files with 8 additions and 10 deletions
|
@ -236,17 +236,18 @@ func (h *Handler) handleIPQuery(id uint16, qType dnsmessage.Type, domain string,
|
|||
var ips []net.IP
|
||||
var err error
|
||||
|
||||
var ttl uint32 = 0
|
||||
var ttl4 uint32
|
||||
var ttl6 uint32
|
||||
|
||||
switch qType {
|
||||
case dnsmessage.TypeA:
|
||||
ips, ttl, err = h.client.LookupIP(domain, dns.IPOption{
|
||||
ips, ttl4, err = h.client.LookupIP(domain, dns.IPOption{
|
||||
IPv4Enable: true,
|
||||
IPv6Enable: false,
|
||||
FakeEnable: true,
|
||||
})
|
||||
case dnsmessage.TypeAAAA:
|
||||
ips, ttl, err = h.client.LookupIP(domain, dns.IPOption{
|
||||
ips, ttl6, err = h.client.LookupIP(domain, dns.IPOption{
|
||||
IPv4Enable: false,
|
||||
IPv6Enable: true,
|
||||
FakeEnable: true,
|
||||
|
@ -259,10 +260,6 @@ func (h *Handler) handleIPQuery(id uint16, qType dnsmessage.Type, domain string,
|
|||
return
|
||||
}
|
||||
|
||||
// if fkr0, ok := h.fdns.(dns.FakeDNSEngineRev0); ok && len(ips) > 0 && fkr0.IsIPInIPPool(net.IPAddress(ips[0])) {
|
||||
// ttl = 1
|
||||
// }
|
||||
|
||||
switch qType {
|
||||
case dnsmessage.TypeA:
|
||||
for i, ip := range ips {
|
||||
|
@ -293,16 +290,17 @@ func (h *Handler) handleIPQuery(id uint16, qType dnsmessage.Type, domain string,
|
|||
}))
|
||||
common.Must(builder.StartAnswers())
|
||||
|
||||
rHeader := dnsmessage.ResourceHeader{Name: dnsmessage.MustNewName(domain), Class: dnsmessage.ClassINET, TTL: ttl}
|
||||
rHeader4 := dnsmessage.ResourceHeader{Name: dnsmessage.MustNewName(domain), Class: dnsmessage.ClassINET, TTL: ttl4}
|
||||
rHeader6 := dnsmessage.ResourceHeader{Name: dnsmessage.MustNewName(domain), Class: dnsmessage.ClassINET, TTL: ttl6}
|
||||
for _, ip := range ips {
|
||||
if len(ip) == net.IPv4len {
|
||||
var r dnsmessage.AResource
|
||||
copy(r.A[:], ip)
|
||||
common.Must(builder.AResource(rHeader, r))
|
||||
common.Must(builder.AResource(rHeader4, r))
|
||||
} else {
|
||||
var r dnsmessage.AAAAResource
|
||||
copy(r.AAAA[:], ip)
|
||||
common.Must(builder.AAAAResource(rHeader, r))
|
||||
common.Must(builder.AAAAResource(rHeader6, r))
|
||||
}
|
||||
}
|
||||
msgBytes, err := builder.Finish()
|
||||
|
|
Loading…
Add table
Reference in a new issue