Expand description
PDK IP Filter Library
Provides IP filtering functionality for allowing or blocking IP addresses and CIDR ranges.
§Primary types
IpFilter: Core filter that checks if an IP address should be allowedFilterType: Enum indicating whether to allow or block listed IPsIpFilterError: Error type for invalid IP addresses
§Example
use ip_filter::IpFilter;
// Create an allowlist filter
let allowlist = IpFilter::allow(&["192.168.1.1", "10.0.0.1"]).unwrap();
assert!(allowlist.is_allowed("192.168.1.1"));
assert!(!allowlist.is_allowed("8.8.8.8"));
// Create a blocklist filter
let blocklist = IpFilter::block(&["192.168.1.0/24"]).unwrap();
assert!(!blocklist.is_allowed("192.168.1.10")); // Blocked
assert!(blocklist.is_allowed("192.168.2.10")); // AllowedStructs§
- IpFilter
- Represents an IP filter that can be used to check if an IP address should be allowed or blocked.
Enums§
- Filter
Type - Represents the type of filter to apply to the IP addresses.
- IpFilter
Error - Errors that can occur during IP filtering operations.