Prevent connections from peers with a banned ip history (#6008)

* Block peers based on past ips

* Remove unused type
This commit is contained in:
Age Manning
2024-06-27 17:35:14 +10:00
committed by GitHub
parent f106533ebc
commit 9b093c8459

View File

@@ -14,7 +14,6 @@ use slog::{debug, error, trace};
use types::EthSpec;
use crate::discovery::enr_ext::EnrExt;
use crate::peer_manager::peerdb::BanResult;
use crate::rpc::GoodbyeReason;
use crate::types::SyncState;
use crate::{metrics, ClearDialError};
@@ -201,7 +200,7 @@ impl<E: EthSpec> NetworkBehaviour for PeerManager<E> {
) -> Result<libp2p::swarm::THandler<Self>, ConnectionDenied> {
trace!(self.log, "Inbound connection"; "peer_id" => %peer_id, "multiaddr" => %remote_addr);
// We already checked if the peer was banned on `handle_pending_inbound_connection`.
if let Some(BanResult::BadScore) = self.ban_status(&peer_id) {
if self.ban_status(&peer_id).is_some() {
return Err(ConnectionDenied::new(
"Connection to peer rejected: peer has a bad score",
));