From: Matt Joiner Date: Mon, 14 Jul 2025 05:32:31 +0000 (+1000) Subject: Reduce ban logging X-Git-Tag: v1.59.0~26 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=106da41487e4a0536215533b76d32e2e0e8c6138;p=btrtrc.git Reduce ban logging --- diff --git a/client.go b/client.go index 442b7138..de598591 100644 --- a/client.go +++ b/client.go @@ -1674,14 +1674,13 @@ func (cl *Client) banPeerIP(ip net.IP) { // We can't take this from string, because it will lose netip's v4on6. net.ParseIP parses v4 // addresses directly to v4on6, which doesn't compare equal with v4. ipAddr, ok := netip.AddrFromSlice(ip) - if !ok { - panic(ip) - } - g.MakeMapIfNilAndSet(&cl.badPeerIPs, ipAddr, struct{}{}) + panicif.False(ok) + g.MakeMapIfNil(&cl.badPeerIPs) + cl.badPeerIPs[ipAddr] = struct{}{} for t := range cl.torrents { t.iterPeers(func(p *Peer) { if p.remoteIp().Equal(ip) { - t.logger.Levelf(log.Warning, "dropping peer %v with banned ip %v", p, ip) + t.slogger().Debug("dropping peer with banned ip", "peer", p, "ip", ip) // Should this be a close? p.drop() } diff --git a/internal/math/math.go b/internal/math/math.go new file mode 100644 index 00000000..c91c24e9 --- /dev/null +++ b/internal/math/math.go @@ -0,0 +1 @@ +package math diff --git a/metainfo/piece_key.go b/metainfo/piece-key.go similarity index 100% rename from metainfo/piece_key.go rename to metainfo/piece-key.go diff --git a/torrent.go b/torrent.go index 02556bfc..c2407696 100644 --- a/torrent.go +++ b/torrent.go @@ -2559,11 +2559,12 @@ func (t *Torrent) pieceHashed(piece pieceIndex, passed bool, hashIoErr error) { // 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.slogger().Warn( + t.slogger().Info( "piece failed hash. banning peer", "piece", piece, "peer", c) c.ban() + // TODO: Check if we now have no available peers for pieces we want. } } }