t.iterPeers(func(p *Peer) {
if p.remoteIp().Equal(ip) {
t.logger.Levelf(log.Warning, "dropping peer %v with banned ip %v", p, ip)
+ // Should this be a close?
p.drop()
}
})
connectionFlags() string
onClose()
onGotInfo(*metainfo.Info)
+ // Drop connection. This may be a no-op if there is no connection.
drop()
+ // Rebuke the peer
+ ban()
String() string
connStatusString() string
cn.t.dropConnection(cn)
}
+func (cn *PeerConn) ban() {
+ cn.t.cl.banPeerIP(cn.remoteIp())
+}
+
func (cn *Peer) netGoodPiecesDirtied() int64 {
return cn._stats.PiecesDirtiedGood.Int64() - cn._stats.PiecesDirtiedBad.Int64()
}
// single peer for a piece, and we never progress that piece to completion, we
// will never smart-ban them. Discovered in
// https://github.com/anacrolix/torrent/issues/715.
- t.logger.Levelf(log.Warning, "banning %v for being sole dirtier of piece %v after failed piece check", c.remoteIp(), piece)
- t.cl.banPeerIP(c.remoteIp())
- c.drop()
+ t.logger.Levelf(log.Warning, "banning %v for being sole dirtier of piece %v after failed piece check", c, piece)
+ c.ban()
}
}
}
p, remoteIp, p.bannableAddr)
}
if _, ok := t.cl.badPeerIPs[netipAddr]; ok {
+ // Should this be a close?
p.drop()
log.Printf("dropped %v for banned remote IP %v", p, netipAddr)
}
return "WS"
}
-// TODO: This is called when banning peers. Perhaps we want to be able to ban webseeds too. We could
-// return bool if this is even possible, and if it isn't, skip to the next drop candidate.
+// Maybe this should drop all existing connections, or something like that.
func (ws *webseedPeer) drop() {}
+func (cn *webseedPeer) ban() {
+ cn.peer.close()
+}
+
func (ws *webseedPeer) handleUpdateRequests() {
// Because this is synchronous, webseed peers seem to get first dibs on newly prioritized
// pieces.