rm extra if; add missing expr for ipv6 subnet

This commit is contained in:
Jimmy Zelinskie 2014-07-17 08:27:08 -04:00
parent f54f688ab2
commit 809735c504

View file

@ -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) {
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) {