diff --git a/stats/stats.go b/stats/stats.go index 7ccfdf5..4476668 100644 --- a/stats/stats.go +++ b/stats/stats.go @@ -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++ diff --git a/tracker/announce.go b/tracker/announce.go index 634cee6..4ec79d1 100644 --- a/tracker/announce.go +++ b/tracker/announce.go @@ -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 } diff --git a/tracker/models/models.go b/tracker/models/models.go index e2cd0ab..cae0cca 100644 --- a/tracker/models/models.go +++ b/tracker/models/models.go @@ -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.