hyperlane-plugin-ip-filter 22.14.1

A zero-allocation IP allowlist/denylist and anti-spoofing client IP extraction plugin for the Hyperlane framework with /8 radix-indexed CIDR lookup, IPv4-mapped IPv6 canonicalization, RFC 7239 Forwarded/X-Forwarded-For right-to-left proxy peeling, and prebuilt 403 wire responses.
Documentation
/// Canonicalized IPv4 or IPv6 CIDR network block.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum IpNet {
    /// IPv4 network represented as `(masked_network, bitmask, prefix_len)`.
    V4 {
        /// Masked IPv4 network bits in host byte order.
        network: u32,
        /// Contiguous high-bit prefix mask.
        mask: u32,
        /// Prefix length in `0..=32`.
        prefix_len: u8,
    },
    /// IPv6 network represented as `(masked_network, bitmask, prefix_len)`.
    V6 {
        /// Masked IPv6 network bits in host byte order.
        network: u128,
        /// Contiguous high-bit prefix mask.
        mask: u128,
        /// Prefix length in `0..=128`.
        prefix_len: u8,
    },
}

/// Enforcement outcome produced by [`CompiledIpFilter::evaluate`].
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum IpFilterAction {
    /// Client IP passed all allowlist and denylist checks.
    Allow,
    /// Client IP was blocked by denylist or missing from non-empty allowlist.
    Deny,
    /// Request path matched the configured skip list.
    Exempt,
}

/// Errors produced when parsing CIDR strings or compiling filter policies.
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum IpFilterError {
    /// Input string was empty after trimming whitespace.
    EmptyCidr,
    /// Address portion could not be parsed as IPv4 or IPv6.
    InvalidIp(String),
    /// Prefix length portion could not be parsed as an unsigned integer.
    InvalidPrefix(String),
    /// Prefix length exceeded 32 (IPv4) or 128 (IPv6).
    PrefixOutOfRange(u8),
}