When banning an IP drop peers that match

This commit is contained in:
Matt Joiner 2022-01-27 15:12:26 +11:00
parent 91ecb1f0aa
commit 162cef5d1b
No known key found for this signature in database
GPG Key ID: 6B990B8185E7F782
1 changed files with 8 additions and 0 deletions

View File

@ -1489,6 +1489,14 @@ func (cl *Client) banPeerIP(ip net.IP) {
cl.badPeerIPs = make(map[string]struct{})
}
cl.badPeerIPs[ip.String()] = 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) {