pub struct HttpFilterConfig {
pub port_filter: Option<PortFilter>,
pub ip_filter: Option<IpFilter>,
pub subnet_filter: Option<SubnetFilter>,
pub mode: FilterMode,
}Expand description
Combined filter configuration
Combines port, IP, and subnet filters with a filter mode (Allow/Deny). All enabled filters must pass for a packet to be processed.
§Examples
use huginn_net_http::{FilterConfig, FilterMode, PortFilter, SubnetFilter};
let filter = FilterConfig::new()
.mode(FilterMode::Allow)
.with_port_filter(PortFilter::new().destination(443))
.with_subnet_filter(
SubnetFilter::new()
.allow("192.168.0.0/16")
.unwrap()
);Fields§
§port_filter: Option<PortFilter>§ip_filter: Option<IpFilter>§subnet_filter: Option<SubnetFilter>§mode: FilterModeImplementations§
Source§impl FilterConfig
impl FilterConfig
Sourcepub fn new() -> FilterConfig
pub fn new() -> FilterConfig
Create a new empty filter configuration
Sourcepub fn mode(self, mode: FilterMode) -> FilterConfig
pub fn mode(self, mode: FilterMode) -> FilterConfig
Set filter mode (Allow/Deny)
§Examples
use huginn_net_http::{FilterConfig, FilterMode};
// Allowlist mode (default) - only matching packets pass
let filter = FilterConfig::new().mode(FilterMode::Allow);
// Denylist mode - matching packets are blocked
let filter = FilterConfig::new().mode(FilterMode::Deny);Sourcepub fn with_port_filter(self, filter: PortFilter) -> FilterConfig
pub fn with_port_filter(self, filter: PortFilter) -> FilterConfig
Add port filter
§Examples
use huginn_net_http::{FilterConfig, PortFilter};
let filter = FilterConfig::new()
.with_port_filter(PortFilter::new().destination(443));Sourcepub fn with_ip_filter(self, filter: IpFilter) -> FilterConfig
pub fn with_ip_filter(self, filter: IpFilter) -> FilterConfig
Add IP filter
§Examples
use huginn_net_http::{FilterConfig, IpFilter};
let filter = FilterConfig::new()
.with_ip_filter(
IpFilter::new()
.allow("8.8.8.8")
.unwrap()
);Sourcepub fn with_subnet_filter(self, filter: SubnetFilter) -> FilterConfig
pub fn with_subnet_filter(self, filter: SubnetFilter) -> FilterConfig
Add subnet filter
§Examples
use huginn_net_http::{FilterConfig, SubnetFilter};
let filter = FilterConfig::new()
.with_subnet_filter(
SubnetFilter::new()
.allow("192.168.0.0/16")
.unwrap()
);Sourcepub fn should_process(
&self,
src_ip: &IpAddr,
dst_ip: &IpAddr,
src_port: u16,
dst_port: u16,
) -> bool
pub fn should_process( &self, src_ip: &IpAddr, dst_ip: &IpAddr, src_port: u16, dst_port: u16, ) -> bool
Check if packet should be processed based on filters (userspace filtering)
This method performs filtering in userspace after packets reach the application. It extracts IP addresses and ports from packet headers and applies the configured filters (port, IP, subnet) according to the filter mode (Allow/Deny).
§Returns
true: Packet passes all filters (should be processed)false: Packet blocked by filters (should be dropped)
§Logic
- If no filters are configured, all packets pass
- In Allow mode: packet must match ALL configured filters
- In Deny mode: packet must NOT match ALL configured filters
Trait Implementations§
Source§impl Clone for FilterConfig
impl Clone for FilterConfig
Source§fn clone(&self) -> FilterConfig
fn clone(&self) -> FilterConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FilterConfig
impl Debug for FilterConfig
Source§impl Default for FilterConfig
impl Default for FilterConfig
Source§fn default() -> FilterConfig
fn default() -> FilterConfig
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for FilterConfig
impl RefUnwindSafe for FilterConfig
impl Send for FilterConfig
impl Sync for FilterConfig
impl Unpin for FilterConfig
impl UnwindSafe for FilterConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more