Setting to disable IP blocking

This commit is contained in:
Mike Dilger 2024-04-12 14:00:37 +12:00
parent cc065ec5b2
commit 27a63495e5
3 changed files with 24 additions and 9 deletions

View File

@ -130,13 +130,16 @@ async fn main() -> Result<(), Error> {
(tcp_stream, hashed_peer)
};
let ip_data = GLOBALS.store.get().unwrap().get_ip_data(hashed_peer.ip())?;
if ip_data.is_banned() {
log::debug!(target: "Client",
"{}: Blocking reconnection until {}",
hashed_peer.ip(),
ip_data.ban_until);
continue;
// Possibly IP block
if ! GLOBALS.config.read().dont_ip_block {
let ip_data = GLOBALS.store.get().unwrap().get_ip_data(hashed_peer.ip())?;
if ip_data.is_banned() {
log::debug!(target: "Client",
"{}: Blocking reconnection until {}",
hashed_peer.ip(),
ip_data.ban_until);
continue;
}
}
if let Some(tls_acceptor) = &maybe_tls_acceptor {
@ -546,9 +549,9 @@ impl WebSocketService {
log::error!(target: "Client", "{}: {e}", self.peer);
if !matches!(e.inner, ChorusError::AuthRequired) {
if msg.len() < 2048 {
log::error!(target: "Client", "{}: msg was {}", self.peer, msg);
log::warn!(target: "Client", "{}: msg was {}", self.peer, msg);
} else {
log::error!(target: "Client", "{}: truncated msg was {} ...", self.peer, &msg[..2048]);
log::warn!(target: "Client", "{}: truncated msg was {} ...", self.peer, &msg[..2048]);
}
}
if !self.replied {

View File

@ -30,6 +30,7 @@ pub struct FriendlyConfig {
pub server_log_level: String,
pub library_log_level: String,
pub client_log_level: String,
pub dont_ip_block: bool,
}
impl Default for FriendlyConfig {
@ -58,6 +59,7 @@ impl Default for FriendlyConfig {
server_log_level: "Info".to_string(),
library_log_level: "Info".to_string(),
client_log_level: "Info".to_string(),
dont_ip_block: false,
}
}
}
@ -88,6 +90,7 @@ impl FriendlyConfig {
server_log_level,
library_log_level,
client_log_level,
dont_ip_block,
} = self;
let mut public_key: Option<Pubkey> = None;
@ -134,6 +137,7 @@ impl FriendlyConfig {
server_log_level,
library_log_level,
client_log_level,
dont_ip_block,
})
}
}
@ -164,6 +168,7 @@ pub struct Config {
pub server_log_level: log::LevelFilter,
pub library_log_level: log::LevelFilter,
pub client_log_level: log::LevelFilter,
pub dont_ip_block: bool,
}
impl Default for Config {

View File

@ -189,3 +189,10 @@ Possible values are: Trace, Debug, Info, Warn, Error
Default is Info
### dont_ip_block
Chorus normally blocks IP addresses for a short period preventing quick reconnections, and for a longer period if the previous connection ended in some error condition.
By setting this variable to true, it will allow all connections.
Default is false.