Skip to main content

Crate pdk_ip_filter_lib

Crate pdk_ip_filter_lib 

Source
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 allowed
  • FilterType: Enum indicating whether to allow or block listed IPs
  • IpFilterError: 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"));  // Allowed

Structs§

IpFilter
Represents an IP filter that can be used to check if an IP address should be allowed or blocked.

Enums§

FilterType
Represents the type of filter to apply to the IP addresses.
IpFilterError
Errors that can occur during IP filtering operations.