From 809735c504b7ea9168ba25c2a580442482ebc4ca Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Thu, 17 Jul 2014 08:27:08 -0400 Subject: [PATCH] rm extra if; add missing expr for ipv6 subnet --- tracker/announce.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tracker/announce.go b/tracker/announce.go index 6434151..221041e 100644 --- a/tracker/announce.go +++ b/tracker/announce.go @@ -257,17 +257,15 @@ func appendSubnetPeers(ipv4s, ipv6s models.PeerList, ann *models.Announce, annou } if ip := peer.IP.To4(); len(ip) == 4 { - if peersLeftInSubnet && ipv4Subnet { - if subnet.Contains(ip) { - ipv4s = append(ipv4s, peer) - count++ - } + if peersLeftInSubnet && ipv4Subnet && subnet.Contains(ip) { + ipv4s = append(ipv4s, peer) + count++ } else if !peersLeftInSubnet && !subnet.Contains(ip) { ipv4s = append(ipv4s, peer) count++ } } else if ip := peer.IP.To16(); len(ip) == 16 { - if peersLeftInSubnet && ipv6Subnet { + if peersLeftInSubnet && ipv6Subnet && subnet.Contains(ip) { ipv6s = append(ipv6s, peer) count++ } else if !peersLeftInSubnet && !subnet.Contains(ip) {