From 9af186eea3d5727f59fb92124e5f57b1ecefba21 Mon Sep 17 00:00:00 2001 From: midefos Date: Sat, 3 May 2025 20:40:57 +0200 Subject: [PATCH] adding unban method --- src/martillo_maldito.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/martillo_maldito.rs b/src/martillo_maldito.rs index 4a8d0ef..a98a4c3 100644 --- a/src/martillo_maldito.rs +++ b/src/martillo_maldito.rs @@ -109,6 +109,10 @@ impl MartilloMaldito { self.append_unique("filter", &format!("-s {} -j DROP", ip)) } + pub fn unban_ip(&self, ip: &str) -> Result<(), Box> { + self.remove_unique("filter", &format!("-s {} -j DROP", ip)) + } + pub fn secure_port( &self, port: u16, @@ -169,6 +173,10 @@ impl MartilloMaldito { self.iptables.append_unique(table, &self.chain, rule) } + fn remove_unique(&self, table: &str, rule: &str) -> Result<(), Box> { + self.iptables.delete(table, &self.chain, rule) + } + fn insert_unique( &self, table: &str,