pub struct SubnetFilter {
pub ipv4_subnets: Vec<Ipv4Network>,
pub ipv6_subnets: Vec<Ipv6Network>,
pub check_source: bool,
pub check_destination: bool,
}Expand description
Subnet filter configuration (CIDR notation)
Filters packets based on subnet membership using CIDR notation. Supports both IPv4 and IPv6 subnets.
§Examples
use huginn_net_http::SubnetFilter;
// Allow only private networks
let filter = SubnetFilter::new()
.allow("192.168.0.0/16").unwrap()
.allow("10.0.0.0/8").unwrap();
// IPv6 subnet
let filter = SubnetFilter::new()
.allow("2001:db8::/32").unwrap();Fields§
§ipv4_subnets: Vec<Ipv4Network>IPv4 subnets to match
ipv6_subnets: Vec<Ipv6Network>IPv6 subnets to match
check_source: boolCheck source, destination, or both?
check_destination: boolImplementations§
Source§impl SubnetFilter
impl SubnetFilter
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new subnet filter that checks both source and destination by default
Sourcepub fn source_only(self) -> Self
pub fn source_only(self) -> Self
Only check source addresses
By default, both source and destination are checked.
Sourcepub fn destination_only(self) -> Self
pub fn destination_only(self) -> Self
Only check destination addresses
By default, both source and destination are checked.
Trait Implementations§
Source§impl Clone for SubnetFilter
impl Clone for SubnetFilter
Source§fn clone(&self) -> SubnetFilter
fn clone(&self) -> SubnetFilter
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 SubnetFilter
impl Debug for SubnetFilter
Source§impl Default for SubnetFilter
impl Default for SubnetFilter
Source§fn default() -> SubnetFilter
fn default() -> SubnetFilter
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SubnetFilter
impl RefUnwindSafe for SubnetFilter
impl Send for SubnetFilter
impl Sync for SubnetFilter
impl Unpin for SubnetFilter
impl UnwindSafe for SubnetFilter
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