Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Do not connect to banned peers #313

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/connect_to_peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async fn check_if_connection_is_allowed(
// Disallow connection if peer is banned via CLI arguments
if cli_arguments.ban.contains(&peer_address.ip()) {
warn!(
"Banned peer {} attempted to connect. Disallowing.",
"Peer {}, banned via CLI argument, attempted to connect. Disallowing.",
peer_address.ip()
);
return InternalConnectionStatus::Refused(ConnectionRefusedReason::BadStanding);
Expand All @@ -95,7 +95,11 @@ async fn check_if_connection_is_allowed(
.get_peer_standing_from_database(peer_address.ip())
.await;

if standing.is_some() && standing.unwrap().standing < -(cli_arguments.peer_tolerance as i32) {
if standing.is_some() && standing.unwrap().standing <= -(cli_arguments.peer_tolerance as i32) {
warn!(
"Peer {}, banned because of bad standing, attempted to connect. Disallowing.",
peer_address.ip()
);
return InternalConnectionStatus::Refused(ConnectionRefusedReason::BadStanding);
}

Expand Down
Loading