updating logs
This commit is contained in:
parent
6de6033205
commit
1c414e204e
@ -1,4 +1,3 @@
|
|||||||
use std::path::PathBuf;
|
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, StructOpt)]
|
||||||
|
12
src/main.rs
12
src/main.rs
@ -78,11 +78,11 @@ async fn main() {
|
|||||||
|
|
||||||
async fn start_ban_server() -> std::io::Result<()> {
|
async fn start_ban_server() -> std::io::Result<()> {
|
||||||
let seconds_iptables = Duration::from_secs(60);
|
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 {
|
spawn(move || loop {
|
||||||
sleep(seconds_iptables);
|
sleep(seconds_iptables);
|
||||||
iptables_save::save_iptables();
|
iptables_save::save_iptables().expect("Failed to save IPTables");
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut child: Child = Command::new("journalctl")
|
let mut child: Child = Command::new("journalctl")
|
||||||
@ -92,11 +92,11 @@ async fn start_ban_server() -> std::io::Result<()> {
|
|||||||
.arg("ssh")
|
.arg("ssh")
|
||||||
.arg("-f")
|
.arg("-f")
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.spawn()?;
|
.spawn()
|
||||||
|
.expect("Failed to start journalctl");
|
||||||
|
|
||||||
let stdout = child.stdout.as_mut().expect("Failed to capture stdout");
|
let stdout = child.stdout.as_mut().expect("Failed to capture stdout");
|
||||||
let mut reader = std::io::BufReader::new(stdout);
|
let mut reader = std::io::BufReader::new(stdout);
|
||||||
|
|
||||||
let iptables = iptables::new(false).unwrap();
|
let iptables = iptables::new(false).unwrap();
|
||||||
let mut login_attempts: HashMap<String, usize> = HashMap::new();
|
let mut login_attempts: HashMap<String, usize> = HashMap::new();
|
||||||
|
|
||||||
@ -117,8 +117,8 @@ async fn start_ban_server() -> std::io::Result<()> {
|
|||||||
|
|
||||||
if let Some(login_attempt) = LoginAttempt::capture(&line) {
|
if let Some(login_attempt) = LoginAttempt::capture(&line) {
|
||||||
info!(
|
info!(
|
||||||
"login attempt from {}@{}:{}",
|
"Login attempt from {} using {} user",
|
||||||
login_attempt.user, login_attempt.ip, login_attempt.port
|
login_attempt.ip, login_attempt.user
|
||||||
);
|
);
|
||||||
|
|
||||||
match login_attempts.get_mut(&login_attempt.ip) {
|
match login_attempts.get_mut(&login_attempt.ip) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user