Skip to content

Commit

Permalink
net: cleanup log levels for blacklist/ ban behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
darkfi committed Jan 23, 2025
1 parent 1549625 commit 30e52c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/net/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use std::{
use darkfi_serial::{
async_trait, AsyncDecodable, AsyncEncodable, SerialDecodable, SerialEncodable, VarInt,
};
use log::{debug, error, info, trace};
use log::{debug, error, info, trace, warn};
use rand::{rngs::OsRng, Rng};
use smol::{
io::{self, AsyncRead, AsyncReadExt, AsyncWriteExt, ReadHalf, WriteHalf},
Expand Down Expand Up @@ -383,7 +383,11 @@ impl Channel {
Ok(()) => {}
// If we're getting messages without dispatchers, it's spam.
Err(Error::MissingDispatcher) => {
debug!(target: "net::channel::main_receive_loop()", "Stopping channel {:?}", self);
warn!(
target: "net::channel::main_receive_loop()",
"MissingDispatcher for command={}, channel={:?}",
command, self
);
if let BanPolicy::Strict = self.p2p().settings().read().await.ban_policy {
self.ban(self.address()).await;
}
Expand Down Expand Up @@ -431,6 +435,7 @@ impl Channel {
};

let last_seen = UNIX_EPOCH.elapsed().unwrap().as_secs();
info!(target: "net::channel::ban()", "Blacklisting peer={}", peer);
self.p2p().hosts().move_host(&peer, last_seen, HostColor::Black).unwrap();
self.stop().await;
debug!(target: "net::channel::ban()", "STOP {:?}", self);
Expand Down
2 changes: 1 addition & 1 deletion src/net/hosts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ impl Hosts {
if self.container.contains(HostColor::Black as usize, addr_) ||
self.block_all_ports(addr_)
{
warn!(
debug!(
target: "net::hosts::filter_addresses",
"[{}] is blacklisted", addr_,
);
Expand Down

0 comments on commit 30e52c5

Please sign in to comment.