| Crates.io | wfp |
| lib.rs | wfp |
| version | 0.0.3 |
| created_at | 2025-08-31 14:52:20.249846+00 |
| updated_at | 2025-09-13 22:44:53.320642+00 |
| description | A Rust library for the Windows Filtering Platform (WFP) API |
| homepage | |
| repository | https://github.com/dlon/wfp-rs |
| max_upload_size | |
| id | 1818614 |
| size | 87,938 |
⚠️ This project is experimental and a work in progress.
A safe Rust library for the Windows Filtering Platform (WFP) API, providing an ergonomic interface for creating and managing network filters on Windows systems.
Add it to your Cargo.toml: cargo add wfp
Here is a simple example adding a sublayer and a blocking rule:
use std::io;
use wfp::{ActionType, FilterBuilder, FilterEngineBuilder, Layer, SubLayerBuilder, Transaction};
fn main() -> io::Result<()> {
println!("Creating WFP filter engine...");
let mut engine = FilterEngineBuilder::default().dynamic().open()?;
std::thread::spawn(move || {
println!("Starting transaction...");
let transaction = Transaction::new(&mut engine)?;
// Create a custom sublayer for organizing our filters
println!("Adding custom sublayer...");
SubLayerBuilder::default()
.name("Example SubLayer")
.description("Custom sublayer for example filters")
.weight(100)
.add(&transaction)?;
// Create a blocking filter for IPv4 outbound connections
println!("Adding blocking filter...");
FilterBuilder::default()
.name("Example Block Filter")
.description("Blocks all outbound IPv4 connections on port 80")
.action(ActionType::Block)
.layer(Layer::ConnectV4)
.condition(
PortConditionBuilder::remote()
.equal(80)
.build(),
)
.add(&transaction)?;
println!("Committing transaction...");
transaction.commit()?;
println!("Filter successfully added!");
Ok::<(), io::Error>(())
})
.join()
.unwrap()?;
println!("Example completed successfully!");
Ok(())
}
See examples for more examples.
Licensed under either of
at your option.
Contributions are welcome! Please feel free to submit a Pull Request.