Crates.io | ipfw-rs |
lib.rs | ipfw-rs |
version | 0.1.0 |
source | src |
created_at | 2024-03-26 23:37:16.56321 |
updated_at | 2024-03-26 23:37:16.56321 |
description | A Rust crate which allows to send commands to the FreeBSD IPFW firewall. |
homepage | |
repository | https://repo.4neko.org/4neko/ipfw-rs |
max_upload_size | |
id | 1187383 |
size | 92,389 |
#ipfw-rs
A issues tracking is at https://gitlab.com/4neko/ipfw-rs
A crate which provides userspace interface to FreeBSD IPFW Firewall which allows to control IPFW directly without executing ipfw(8)
every time when it is required to block network host or to check the list.
This crate supports only actual and recent FreeBSD version which is 14.0, but it seems that protocol did not changed much, so may work on FreeBSD 13!
Add, Remove, Test commands on tables (a list of hosts: IP/IPv6/DNS at the moment)
Flush table
extern crate ipfw_rs;
use ipfw_rs::{Ipfw, IpfwCmd};
fn main()
{
let ipfw = Ipfw::new().unwrap();
let res =
ipfw.ipfw_table_handler("testtable", IpfwCmd::Add { hosts: vec!["127.0.1.1", "127.0.2.0/24"], req_atomic_op: true }, false);
match res
{
Ok(r) => println!("res: '{}'", r),
Err(e) => println!("err: '{}'", e)
}
let res =
ipfw.ipfw_table_handler("testtable", IpfwCmd::Test { hosts: vec!["127.0.1.1", "127.0.2.0/24"]}, false);
match res
{
Ok(r) => println!("res: '{}'", r),
Err(e) => println!("err: '{}'", e)
}
let res =
ipfw.ipfw_table_handler("testtable", IpfwCmd::Flush, false); //{ hosts: vec!["127.0.1.2"] }, false);// { hosts: vec!["127.0.1.1", "127.0.2.0/24"], req_atomic_op: true }, false);
match res
{
Ok(r) => println!("res: '{}'", r),
Err(e) => println!("err: '{}'", e)
}
println!("Hello, world!");
}