hyperlane-plugin-ip-filter 22.14.0

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
/// Context attribute key storing the resolved [`ClientIp`] metadata.
pub const ATTR_CLIENT_IP: &str = "hyperlane_plugin_client_ip";

/// Default response body emitted when a request IP is rejected.
pub const DEFAULT_REJECT_BODY: &[u8] = b"Forbidden";

/// Default `Content-Type` header emitted on rejected requests.
pub const DEFAULT_REJECT_CONTENT_TYPE: &str = "text/plain; charset=utf-8";

/// Default maximum number of trusted proxy hops peeled right-to-left.
pub const DEFAULT_MAX_TRUSTED_HOPS: usize = 16;

/// Number of `/8` radix buckets in [`CidrTable`].
pub(crate) const CIDR_BUCKET_COUNT: usize = 256;

/// Maximum CIDR prefix length for IPv4 addresses.
pub(crate) const IPV4_MAX_PREFIX: u8 = 32;

/// Maximum CIDR prefix length for IPv6 addresses.
pub(crate) const IPV6_MAX_PREFIX: u8 = 128;

/// Prefix length threshold separating short prefixes from `/8` radix buckets.
pub(crate) const RADIX_PREFIX_BITS: u8 = 8;

/// Prefix length of the IPv4-mapped IPv6 subnet `::ffff:0:0/96`.
pub(crate) const IPV4_MAPPED_PREFIX_BITS: u8 = 96;

/// Leading 96-bit pattern identifying an IPv4-mapped IPv6 address.
pub(crate) const IPV4_MAPPED_HIGH_96: u128 = 0x0000_0000_0000_0000_0000_ffff_0000_0000;

/// Mask extracting the upper 96 bits of an IPv6 address.
pub(crate) const IPV6_HIGH_96_MASK: u128 = 0xffff_ffff_ffff_ffff_ffff_ffff_0000_0000;

/// RFC 7239 `Forwarded` directive prefix selecting the client address parameter.
pub(crate) const FORWARDED_FOR_PREFIX: &str = "for=";

/// RFC 7239 sentinel token denoting an unknown forwarded address.
pub(crate) const FORWARDED_UNKNOWN: &str = "unknown";

/// Error message returned when parsing an empty CIDR string.
pub(crate) const ERR_EMPTY_CIDR: &str = "empty CIDR specification";

/// Error message returned when the IP address part of a CIDR fails to parse.
pub(crate) const ERR_INVALID_IP: &str = "invalid IP address in CIDR";

/// Error message returned when the prefix length fails to parse as an integer.
pub(crate) const ERR_INVALID_PREFIX: &str = "invalid CIDR prefix length";

/// Error message returned when the prefix length exceeds the address family width.
pub(crate) const ERR_PREFIX_OUT_OF_RANGE: &str = "CIDR prefix length out of range";