2024-05-28 16:03:32 +02:00
|
|
|
use std::path::PathBuf;
|
|
|
|
use structopt::StructOpt;
|
|
|
|
|
|
|
|
#[derive(Debug, StructOpt)]
|
2024-07-23 21:14:51 +02:00
|
|
|
#[structopt(
|
|
|
|
name = "martillo-maldito",
|
|
|
|
about = "A simple iptables wrapper, including a ban server"
|
|
|
|
)]
|
|
|
|
pub enum Cli {
|
2024-05-28 16:03:32 +02:00
|
|
|
#[structopt(about = "Initialize ban server")]
|
|
|
|
BanServer {
|
|
|
|
#[structopt(name = "Ssh auth log file", short = "f", long = "ssh-file")]
|
|
|
|
ssh_auth_log: PathBuf,
|
|
|
|
#[structopt(name = "Iptables save file", short = "s", long = "iptables-save")]
|
|
|
|
iptables_save: Option<PathBuf>,
|
|
|
|
},
|
2024-07-23 21:14:51 +02:00
|
|
|
#[structopt(about = "List all banned ips")]
|
2024-07-21 13:01:23 +02:00
|
|
|
ListBannedIps,
|
2024-07-23 21:14:51 +02:00
|
|
|
#[structopt(about = "List all secured ports")]
|
|
|
|
ListSecuredPorts {
|
|
|
|
#[structopt(name = "Docker", short = "d", long = "docker")]
|
|
|
|
docker: bool,
|
|
|
|
},
|
|
|
|
#[structopt(about = "Map secured ports to allowed ips")]
|
|
|
|
MapSecuredPortsAllowedIps {
|
|
|
|
#[structopt(name = "Docker", short = "d", long = "docker")]
|
|
|
|
docker: bool,
|
|
|
|
},
|
2024-06-09 15:17:36 +02:00
|
|
|
#[structopt(about = "Check if a port is secured")]
|
|
|
|
IsPortSecured {
|
|
|
|
#[structopt(name = "Port to check", short = "p", long = "port")]
|
|
|
|
port: u16,
|
|
|
|
#[structopt(name = "Docker", short = "d", long = "docker")]
|
|
|
|
docker: bool,
|
|
|
|
},
|
2024-05-28 16:03:32 +02:00
|
|
|
#[structopt(about = "Ban port")]
|
2024-07-23 21:14:51 +02:00
|
|
|
SecurePort {
|
2024-05-28 16:03:32 +02:00
|
|
|
#[structopt(name = "Port to ban", short = "p", long = "port")]
|
|
|
|
port: u16,
|
2024-05-28 17:31:14 +02:00
|
|
|
#[structopt(name = "Docker", short = "d", long = "docker")]
|
|
|
|
docker: bool,
|
2024-05-28 21:13:53 +02:00
|
|
|
#[structopt(name = "Position", short = "P", long = "position")]
|
|
|
|
position: Option<i32>,
|
2024-05-28 16:03:32 +02:00
|
|
|
},
|
|
|
|
#[structopt(about = "Unban port")]
|
2024-07-23 21:14:51 +02:00
|
|
|
UnsecurePort {
|
2024-05-28 16:03:32 +02:00
|
|
|
#[structopt(name = "Port to unban", short = "p", long = "port")]
|
|
|
|
port: u16,
|
2024-05-28 17:31:14 +02:00
|
|
|
#[structopt(name = "Docker", short = "d", long = "docker")]
|
|
|
|
docker: bool,
|
2024-05-28 16:03:32 +02:00
|
|
|
},
|
|
|
|
#[structopt(about = "Allow ip and port")]
|
2024-07-23 21:14:51 +02:00
|
|
|
AllowIpForPort {
|
2024-05-28 16:03:32 +02:00
|
|
|
#[structopt(name = "Ip to allow", short = "i", long = "ip")]
|
|
|
|
ip: String,
|
|
|
|
#[structopt(name = "Port to allow", short = "p", long = "port")]
|
|
|
|
port: u16,
|
2024-05-28 17:31:14 +02:00
|
|
|
#[structopt(name = "Docker", short = "d", long = "docker")]
|
|
|
|
docker: bool,
|
2024-05-28 21:13:53 +02:00
|
|
|
#[structopt(name = "Position", short = "P", long = "position")]
|
|
|
|
position: Option<i32>,
|
|
|
|
},
|
|
|
|
#[structopt(about = "Allow port for only an ip")]
|
2024-07-23 21:14:51 +02:00
|
|
|
OnlyIpForPort {
|
2024-05-28 21:13:53 +02:00
|
|
|
#[structopt(name = "Ip to allow", short = "i", long = "ip")]
|
|
|
|
ip: String,
|
|
|
|
#[structopt(name = "Port to allow", short = "p", long = "port")]
|
|
|
|
port: u16,
|
|
|
|
#[structopt(name = "Docker", short = "d", long = "docker")]
|
|
|
|
docker: bool,
|
2024-05-28 16:03:32 +02:00
|
|
|
},
|
2024-07-23 21:14:51 +02:00
|
|
|
#[structopt(about = "Removes an allow port for an ip")]
|
|
|
|
RemoveAllowIpPort {
|
2024-05-28 16:03:32 +02:00
|
|
|
#[structopt(name = "Ip to remove", short = "i", long = "ip")]
|
|
|
|
ip: String,
|
|
|
|
#[structopt(name = "Port to remove", short = "p", long = "port")]
|
|
|
|
port: u16,
|
2024-05-28 17:31:14 +02:00
|
|
|
#[structopt(name = "Docker", short = "d", long = "docker")]
|
|
|
|
docker: bool,
|
2024-05-28 16:03:32 +02:00
|
|
|
},
|
2024-07-23 21:14:51 +02:00
|
|
|
#[structopt(about = "Saves the IPTables configuration")]
|
|
|
|
SaveIPTables {
|
|
|
|
#[structopt(name = "Iptables save file", short = "s", long = "iptables-save")]
|
|
|
|
iptables_save: Option<PathBuf>,
|
|
|
|
},
|
2024-05-28 16:03:32 +02:00
|
|
|
}
|