Expand description
§Windows Filtering Platform (WFP) Rust library
This crate provides a safe Rust library around the Windows Filtering Platform API, allowing you to create and manage network filters on Windows.
§Overview
The Windows Filtering Platform is a set of APIs that allow applications to handle filtering and processing of network traffic. This crate provides a type-safe interface to create filters that can block or permit network traffic based on various criteria.
§Basic Usage
use wfp::{FilterEngineBuilder, FilterBuilder, PortConditionBuilder, ActionType, Layer, Transaction};
use std::io;
fn main() -> io::Result<()> {
// Open a dynamic filter engine session
let mut engine = FilterEngineBuilder::default().dynamic().open()?;
// Create a transaction for atomic filter operations
let transaction = Transaction::new(&mut engine)?;
// Create and add a filter
FilterBuilder::default()
.name("Block outbound connections")
.description("Blocks all outbound IPv4 connections")
.action(ActionType::Block)
.layer(Layer::ConnectV4)
.condition(
PortConditionBuilder::remote()
.equal(80)
.build(),
)
.add(&transaction)?;
// Commit the transaction
transaction.commit()?;
Ok(())
}§Examples
See the examples/ directory for more usage examples.
Run examples with: cargo run --example <example>
Structs§
- AppId
Condition Builder - Typed builder for application ID conditions.
- Condition
- Internal representation of a built condition.
- Filter
Builder - Builder for creating Windows Filtering Platform filters.
- Filter
Engine - Represents an active connection to the Windows Filtering Platform engine.
- Filter
Engine Builder - Builder for creating a Windows Filtering Platform engine session.
- Filter
Enum Item - A WFP filter
- Filter
Enumerator - An iterator over filters.
- Port
Condition Builder - Typed builder for port-based conditions.
- Protocol
Condition Builder - Typed builder for protocol-based conditions.
- SubLayer
Builder - Builder for creating Windows Filtering Platform sublayers.
- Transaction
- Represents a transactional context for filter operations.
Enums§
- Action
Type - Specifies the action to take when a filter matches network traffic.
- Condition
Field - Represents different types of filter conditions that can be applied to network traffic.
- Layer
- Specifies the network layer at which a filter operates.
- Match
Type - Specifies how a condition value should be matched against network traffic.
Functions§
- delete_
filter - Delete a filter by its ID.
- delete_
filter_ by_ guid - Delete a filter by its GUID.