diff --git a/app/dns/nameserver_doh.go b/app/dns/nameserver_doh.go index db61e831a40..88350f2ee11 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 - if option.IPv4Enable { + switch { + case option.IPv4Enable: ips, err4 = record.A.getIPs() - } - - if option.IPv6Enable { + fallthrough + case 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 b0618ecee40..f2e2573edfa 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 - if option.IPv4Enable { + switch { + case option.IPv4Enable: ips, err4 = record.A.getIPs() - } - - if option.IPv6Enable { + fallthrough + case 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 c114d6152f0..be51ffb57c8 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 - if option.IPv4Enable { + switch { + case option.IPv4Enable: ips, err4 = record.A.getIPs() - } - - if option.IPv6Enable { + fallthrough + case 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 70c8beab48c..5d88da148e3 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 - if option.IPv4Enable { + switch { + case option.IPv4Enable: ips, err4 = record.A.getIPs() - } - - if option.IPv6Enable { + fallthrough + case option.IPv6Enable: ip6, err6 = record.AAAA.getIPs() ips = append(ips, ip6...) }