1
0

adding unban method

This commit is contained in:
midefos 2025-05-03 20:40:57 +02:00
parent ed4e83a0d2
commit 9af186eea3

View File

@ -109,6 +109,10 @@ impl MartilloMaldito {
self.append_unique("filter", &format!("-s {} -j DROP", ip))
}
pub fn unban_ip(&self, ip: &str) -> Result<(), Box<dyn std::error::Error>> {
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<dyn std::error::Error>> {
self.iptables.delete(table, &self.chain, rule)
}
fn insert_unique(
&self,
table: &str,