From: Matt Joiner Date: Thu, 27 Jan 2022 04:09:05 +0000 (+1100) Subject: Ban peers for dirtying pieces if they are solely responsible X-Git-Tag: v1.42.0~8^2^2~10 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=60057327b332ef9fdfe37f7240f69b3c08cc3549;p=btrtrc.git Ban peers for dirtying pieces if they are solely responsible --- diff --git a/torrent.go b/torrent.go index 22b4bb57..d6ff2dbc 100644 --- a/torrent.go +++ b/torrent.go @@ -2042,8 +2042,14 @@ func (t *Torrent) pieceHashed(piece pieceIndex, passed bool, hashIoErr error) { if len(bannableTouchers) >= 1 { c := bannableTouchers[0] - log.Printf("would have banned %v for touching piece %v after failed piece check", c.remoteIp(), piece) - if false { + if len(bannableTouchers) != 1 { + t.logger.Levelf(log.Warning, "would have banned %v for touching piece %v after failed piece check", c.remoteIp(), piece) + } else { + // Turns out it's still useful to ban peers like this because if there's only a + // 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() }