anacrolix / torrent

Full-featured BitTorrent client package and utilities
Mozilla Public License 2.0
5.39k stars 615 forks source link

PeerConn log flood and banned IPs with v1.51+ #841

Closed tsynik closed 1 year ago

tsynik commented 1 year ago

after switching torrserver from torrent v1.49.1 release to v1.51.1 and v1.51.3, there are many banned IPs with messages like

WRN would have banned x.x.x.x for touching piece XXX after failed piece check [github.com/anacrolix/torrent torrent.go:2192]

and many log lines from peerconn.go:618

WRN *torrent.PeerConn 0xc001326a80: error reading chunk for peer Request {623 {2621440 16384}}: waiting for alloc limit reservation: reservation cancelled [github.com/anacrolix/torrent peerconn.go:618]

with the same timestamps.

This doesn't happening with v1.49.1 release

Full log included: TorrServer-MatriX_123_3.txt

anacrolix commented 1 year ago

The reservation failure is introduced by 12db16c478cac89d0767cceac5dfc2fa75f7abb1.

anacrolix commented 1 year ago

The ban message should have been around for a while, but it shouldn't be a warning, I'll demote that to debug.

anacrolix commented 1 year ago

@tsynik should be fixed in main, thanks for the report!

anacrolix commented 1 year ago

@tsynik if you can confirm the fix works, I'll release the next version.

tsynik commented 1 year ago

The ban message should have been around for a while, but it shouldn't be a warning, I'll demote that to debug.

But it's a question why it doesn't happening before on v1.49.1 and earlier releases with same log level. Before smartban realization, we see such false positive bans in TorrServer when client went with rewind video back to blocks outside current cache (they already was downloaded and deleted by range checker), but it was fixed with smartban and doesn't exist till torrent v1.51. https://github.com/anacrolix/torrent/issues/704

anacrolix commented 1 year ago

It's a good question. I haven't touched that part of the code in a long while. It's worth remembering that the network is not deterministic. It's also the same piece failing consistently in the log. It's either a malicious peer, or some data corruption. The log message tells you the the old pre-smartban behaviour would have banned the user, but it's not, so it makes sense that it could occur multiple times.

tsynik commented 1 year ago

if you can confirm the fix works, I'll release the next version.

Looks like PeerConn messages are gone. Thanks! About IP bans not sure, I'll look into it later.

anacrolix commented 1 year ago

v1.52.0.