From 1c414e204e02748fdfea696c6e68125e625d30b9 Mon Sep 17 00:00:00 2001 From: midefos Date: Sun, 22 Sep 2024 03:49:35 +0200 Subject: [PATCH] updating logs --- src/cli.rs | 1 - src/main.rs | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 32402cc..96b4c41 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,4 +1,3 @@ -use std::path::PathBuf; use structopt::StructOpt; #[derive(Debug, StructOpt)] diff --git a/src/main.rs b/src/main.rs index 006e388..604a87a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -78,11 +78,11 @@ async fn main() { async fn start_ban_server() -> std::io::Result<()> { let seconds_iptables = Duration::from_secs(60); - info!("saving IPTables every {} secs", seconds_iptables.as_secs()); + info!("Saving IPTables every {} secs", seconds_iptables.as_secs()); spawn(move || loop { sleep(seconds_iptables); - iptables_save::save_iptables(); + iptables_save::save_iptables().expect("Failed to save IPTables"); }); let mut child: Child = Command::new("journalctl") @@ -92,11 +92,11 @@ async fn start_ban_server() -> std::io::Result<()> { .arg("ssh") .arg("-f") .stdout(Stdio::piped()) - .spawn()?; + .spawn() + .expect("Failed to start journalctl"); let stdout = child.stdout.as_mut().expect("Failed to capture stdout"); let mut reader = std::io::BufReader::new(stdout); - let iptables = iptables::new(false).unwrap(); let mut login_attempts: HashMap = HashMap::new(); @@ -117,8 +117,8 @@ async fn start_ban_server() -> std::io::Result<()> { if let Some(login_attempt) = LoginAttempt::capture(&line) { info!( - "login attempt from {}@{}:{}", - login_attempt.user, login_attempt.ip, login_attempt.port + "Login attempt from {} using {} user", + login_attempt.ip, login_attempt.user ); match login_attempts.get_mut(&login_attempt.ip) {