From 4a2520d6fc49c0e3a4e6d719c53eb949464cfa13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E3=81=AE=E3=81=8B=E3=81=88=E3=81=A7?= Date: Thu, 26 Aug 2021 22:49:45 +0800 Subject: [PATCH] Fix: response AAAA records in TypeA query --- app/dns/nameserver_doh.go | 8 ++++---- app/dns/nameserver_quic.go | 8 ++++---- app/dns/nameserver_tcp.go | 8 ++++---- app/dns/nameserver_udp.go | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/dns/nameserver_doh.go b/app/dns/nameserver_doh.go index 88350f2ee11..db61e831a40 100644 --- a/app/dns/nameserver_doh.go +++ b/app/dns/nameserver_doh.go @@ -304,11 +304,11 @@ func (s *DoHNameServer) findIPsForDomain(domain string, option dns_feature.IPOpt var ips []net.Address var ip6 []net.Address - switch { - case option.IPv4Enable: + if option.IPv4Enable { ips, err4 = record.A.getIPs() - fallthrough - case option.IPv6Enable: + } + + if option.IPv6Enable { ip6, err6 = record.AAAA.getIPs() ips = append(ips, ip6...) } diff --git a/app/dns/nameserver_quic.go b/app/dns/nameserver_quic.go index f2e2573edfa..b0618ecee40 100644 --- a/app/dns/nameserver_quic.go +++ b/app/dns/nameserver_quic.go @@ -241,11 +241,11 @@ func (s *QUICNameServer) findIPsForDomain(domain string, option dns_feature.IPOp var ips []net.Address var ip6 []net.Address - switch { - case option.IPv4Enable: + if option.IPv4Enable { ips, err4 = record.A.getIPs() - fallthrough - case option.IPv6Enable: + } + + if option.IPv6Enable { ip6, err6 = record.AAAA.getIPs() ips = append(ips, ip6...) } diff --git a/app/dns/nameserver_tcp.go b/app/dns/nameserver_tcp.go index be51ffb57c8..c114d6152f0 100644 --- a/app/dns/nameserver_tcp.go +++ b/app/dns/nameserver_tcp.go @@ -283,11 +283,11 @@ func (s *TCPNameServer) findIPsForDomain(domain string, option dns_feature.IPOpt var ips []net.Address var ip6 []net.Address - switch { - case option.IPv4Enable: + if option.IPv4Enable { ips, err4 = record.A.getIPs() - fallthrough - case option.IPv6Enable: + } + + if option.IPv6Enable { ip6, err6 = record.AAAA.getIPs() ips = append(ips, ip6...) } diff --git a/app/dns/nameserver_udp.go b/app/dns/nameserver_udp.go index 5d88da148e3..70c8beab48c 100644 --- a/app/dns/nameserver_udp.go +++ b/app/dns/nameserver_udp.go @@ -223,11 +223,11 @@ func (s *ClassicNameServer) findIPsForDomain(domain string, option dns_feature.I var ips []net.Address var ip6 []net.Address - switch { - case option.IPv4Enable: + if option.IPv4Enable { ips, err4 = record.A.getIPs() - fallthrough - case option.IPv6Enable: + } + + if option.IPv6Enable { ip6, err6 = record.AAAA.getIPs() ips = append(ips, ip6...) }