pub struct IpFilter {
pub enabled: bool,
/* 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.
Fields§
§enabled: boolMaster enabled switch — when false, is_blocked short-circuits to
false regardless of configured ranges (live bans rebuild semantics).
Plain bool not AtomicBool (per M225 OV F2b): IpFilter carries
#[derive(Clone)] and AtomicBool is not Clone. Mutation is safe
because the live filter is wrapped in Arc<RwLock<IpFilter>> at the
session level; writers take the write lock through apply_settings.
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.