pub struct IpFilter { /* private fields */ }Expand description
IP address filter supporting both IPv4 and IPv6 ranges.
Flags: 0 = allowed, non-zero = blocked. Local/private network addresses are always exempt from filtering.
Implementations§
Source§impl IpFilter
impl IpFilter
Sourcepub fn add_rule(&mut self, first: IpAddr, last: IpAddr, flags: u32)
pub fn add_rule(&mut self, first: IpAddr, last: IpAddr, flags: u32)
Add a rule blocking (or allowing) a range of IP addresses.
Both endpoints must be the same address family (both v4 or both v6). Mixed families are silently ignored.
Sourcepub fn is_blocked(&self, addr: IpAddr) -> bool
pub fn is_blocked(&self, addr: IpAddr) -> bool
Check if an address is blocked by the filter.
Local/private network addresses (RFC 1918, loopback, link-local) are
always exempt and return false even if they fall within a blocked range.
Sourcepub fn num_ranges(&self) -> usize
pub fn num_ranges(&self) -> usize
Total number of non-zero-flag ranges across both address families.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for IpFilter
impl RefUnwindSafe for IpFilter
impl Send for IpFilter
impl Sync for IpFilter
impl Unpin for IpFilter
impl UnsafeUnpin for IpFilter
impl UnwindSafe for IpFilter
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