From b68ab1db128bfe5a15e5ac7c91b00bc5c8f60d5a Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 27 Jan 2022 15:12:26 +1100 Subject: [PATCH] When banning an IP drop peers that match --- client.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client.go b/client.go index fae9cf27..4986424c 100644 --- a/client.go +++ b/client.go @@ -1501,6 +1501,14 @@ func (cl *Client) banPeerIP(ip net.IP) { panic(ip) } generics.MakeMapIfNilAndSet(&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) + p.drop() + } + }) + } } func (cl *Client) newConnection(nc net.Conn, outgoing bool, remoteAddr PeerRemoteAddr, network, connString string) (c *PeerConn) { -- 2.48.1