10 releases (4 stable)
1.4.7 | Dec 30, 2023 |
---|---|
1.4.5 | Jan 19, 2023 |
0.2.4 | Jan 16, 2023 |
0.1.2 | Jan 16, 2023 |
#172 in Operating systems
40 downloads per month
16KB
253 lines
About Project
UFW app profile written in pure rust.
Implementation:
ufwprofile = "" #check latest version above
Or
cargo add ufwprofile
Example
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(())
}
Drawbacks
This is hardcoded dependency
- The config file is hardcoded.
- The path is assumed to be
/etc/ufw/applications.d
Changelog
check CHANGELOG.md
Dependencies
~2.3–3.5MB
~59K SLoC