Fix semantics of seed stats, fix Peer.IPv6() always returning true
This commit is contained in:
parent
26f87139e0
commit
e17c984ec8
3 changed files with 11 additions and 5 deletions
|
@ -122,12 +122,16 @@ func (s *Stats) handleEvents() {
|
|||
s.IPv4Peers.Left++
|
||||
case ReapedLeechIPv4:
|
||||
s.IPv4Peers.Reaped++
|
||||
|
||||
case NewSeedIPv4:
|
||||
s.IPv4Peers.SeedsJoined++
|
||||
s.IPv4Peers.Joined++
|
||||
case DeletedSeedIPv4:
|
||||
s.IPv4Peers.SeedsLeft++
|
||||
s.IPv4Peers.Left++
|
||||
case ReapedSeedIPv4:
|
||||
s.IPv4Peers.SeedsReaped++
|
||||
s.IPv4Peers.Reaped++
|
||||
|
||||
case CompletedIPv6:
|
||||
s.IPv6Peers.Completed++
|
||||
|
@ -137,12 +141,16 @@ func (s *Stats) handleEvents() {
|
|||
s.IPv6Peers.Left++
|
||||
case ReapedLeechIPv6:
|
||||
s.IPv6Peers.Reaped++
|
||||
|
||||
case NewSeedIPv6:
|
||||
s.IPv6Peers.SeedsJoined++
|
||||
s.IPv6Peers.Joined++
|
||||
case DeletedSeedIPv6:
|
||||
s.IPv6Peers.SeedsLeft++
|
||||
s.IPv6Peers.Left++
|
||||
case ReapedSeedIPv6:
|
||||
s.IPv6Peers.SeedsReaped++
|
||||
s.IPv6Peers.Reaped++
|
||||
|
||||
case NewTorrent:
|
||||
s.TorrentsAdded++
|
||||
|
|
|
@ -259,9 +259,7 @@ func appendPeers(ipv4s, ipv6s models.PeerList, ann *models.Announce, announcer *
|
|||
for _, peer := range peers {
|
||||
if count >= wanted {
|
||||
break
|
||||
}
|
||||
|
||||
if peersEquivalent(&peer, announcer) {
|
||||
} else if peersEquivalent(&peer, announcer) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
|
@ -71,11 +71,11 @@ func NewPeer(a *Announce, u *User, t *Torrent) *Peer {
|
|||
}
|
||||
|
||||
func (p *Peer) IPv4() bool {
|
||||
return len(p.IP.To4()) == 4
|
||||
return p.IP.To4() != nil
|
||||
}
|
||||
|
||||
func (p *Peer) IPv6() bool {
|
||||
return len(p.IP.To16()) == 16
|
||||
return !p.IPv4()
|
||||
}
|
||||
|
||||
// Torrent is a swarm for a given torrent file.
|
||||
|
|
Loading…
Add table
Reference in a new issue