forked from midefos/martillo-maldito
WIP list banned ips
This commit is contained in:
1 parent
8256b0358d
commit
78c0af4d04
4 files changed
+79
-55
No files matched your search
@@ -15,6 +15,24 @@ pub fn is_port_secured(port: u16, docker: bool) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn list_banned_ips() -> Vec<String> {
|
||||
let iptables = iptables::new(false).unwrap();
|
||||
let rules = iptables.list("filter", &get_chain(false));
|
||||
if rules.is_err() {
|
||||
return vec![];
|
||||
}
|
||||
|
||||
// TODO: Remove after testing
|
||||
println!("{:?}", rules);
|
||||
|
||||
rules
|
||||
.unwrap()
|
||||
.iter()
|
||||
.filter(|r| r.contains("--source") && r.contains("-j DROP"))
|
||||
.map(|r| r.to_string())
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn ban_port(port: u16, docker: bool, position: Option<i32>) {
|
||||
let iptables = iptables::new(false).unwrap();
|
||||
|
||||
|
||||
Reference in new issue
Block a user