Skip to content

Commit afab24a

Browse files
committed
Simplify IPv4/IPv6 address split logic for resolveUsingSystem
1 parent af6c4f8 commit afab24a

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

dnscrypt-proxy/xtransport.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -341,15 +341,9 @@ func (xTransport *XTransport) resolveUsingSystem(host string) (ip net.IP, ttl ti
341341
ips := make([]net.IP, 0)
342342
for _, ip := range foundIPs {
343343
if foundIP := net.ParseIP(ip); foundIP != nil {
344-
if xTransport.useIPv4 {
345-
if ipv4 := foundIP.To4(); ipv4 != nil {
346-
ips = append(ips, foundIP)
347-
}
348-
}
349-
if xTransport.useIPv6 {
350-
if foundIP.To4() == nil {
351-
ips = append(ips, foundIP)
352-
}
344+
isIPv4 := foundIP.To4() != nil
345+
if (isIPv4 && xTransport.useIPv4) || (!isIPv4 && xTransport.useIPv6) {
346+
ips = append(ips, foundIP)
353347
}
354348
}
355349
}

0 commit comments

Comments
 (0)