Crates.io | ufwprofile |
lib.rs | ufwprofile |
version | 1.4.7 |
source | src |
created_at | 2023-01-16 05:24:49.982464 |
updated_at | 2023-12-30 13:42:14.524623 |
description | UFW app profile written in pure rust |
homepage | https://www.ssdd.dev/rustufwapp-profile |
repository | https://github.com/ssddOnTop/rust-ufw-app-profile |
max_upload_size | |
id | 759875 |
size | 17,760 |
UFW app profile written in pure rust.
ufwprofile = "" #check latest version above
Or
cargo add ufwprofile
fn main() -> anyhow::Result<()> {
if ufwprofile::UFWConf::check_write_permission() {
//checks if ufw exists and the path /etc/ufw/applications.d is writable
let conf = ufwprofile::UFWConf::init("AppName", "Title", "Description")?
.append_ports("80", "")?
.append_ports("81:82", "tcp")?
.append_ports("84", "udp")?
.append_ports("83", "")?
.append_ports("8000", "tcp")?;
if ufwprofile::UFWConf::is_root() {
// check if the app has root permission.
println!("{}", conf.try_adding_to_ufw(true).unwrap());
} else {
println!("{}", conf.try_write_with_sudo(true).unwrap());
}
} else {
println!("Unable to write");
}
Ok(())
}
/etc/ufw/applications.d
check CHANGELOG.md