torrent.go | 15 ++++++--------- diff --git a/torrent.go b/torrent.go index 69ad0ca0b02c78be72f1fdff4ecdc03e5542c36e..f058a72f5d52510bc6e53e8ce6831ff2955f10bd 100644 --- a/torrent.go +++ b/torrent.go @@ -245,16 +245,16 @@ } func (t *Torrent) addPeer(p Peer) { cl := t.cl - t.openNewConns() - if len(t.peers) >= cl.config.TorrentPeersHighWater { + peersAddedBySource.Add(string(p.Source), 1) + if cl.badPeerIPPort(p.IP, p.Port) { + torrent.Add("peers not added because of bad addr", 1) return } - key := peersKey{string(p.IP), p.Port} - if _, ok := t.peers[key]; ok { + t.openNewConns() + if len(t.peers) >= cl.config.TorrentPeersHighWater { return } - t.peers[key] = p - peersAddedBySource.Add(string(p.Source), 1) + t.peers[peersKey{string(p.IP), p.Port}] = p t.openNewConns() } @@ -1395,9 +1395,6 @@ } func (t *Torrent) addPeers(peers []Peer) { for _, p := range peers { - if t.cl.badPeerIPPort(p.IP, p.Port) { - continue - } t.addPeer(p) } }