1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/// Context attribute key storing the resolved [`ClientIp`](crate::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: & = 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 const CIDR_BUCKET_COUNT: usize = 256;
/// Length of the CSR `/8` bucket offset table (`CIDR_BUCKET_COUNT + 1`).
pub const CIDR_OFFSET_LEN: usize = CIDR_BUCKET_COUNT + 1;
/// Maximum merged interval count stored inline inside [`CidrTable`] without heap allocation.
pub const CIDR_INLINE_LIMIT: usize = 4;
/// Maximum per-bucket interval count scanned linearly before binary searching.
pub const CIDR_BUCKET_LINEAR_LIMIT: usize = 4;
/// Threshold above which exact exempt paths switch from linear slice scan to hash set.
pub const EXEMPT_SET_THRESHOLD: usize = 4;
/// Maximum CIDR prefix length for IPv4 addresses.
pub const IPV4_MAX_PREFIX: u8 = 32;
/// Maximum CIDR prefix length for IPv6 addresses.
pub const IPV6_MAX_PREFIX: u8 = 128;
/// Mask covering the host 24 bits inside one IPv4 `/8` block.
pub const IPV4_SLASH8_HOST_MASK: u32 = 0x00FF_FFFF;
/// Mask covering the host 120 bits inside one IPv6 `/8` block.
pub const IPV6_SLASH8_HOST_MASK: u128 = - 1;
/// Prefix length of the IPv4-mapped IPv6 subnet `::ffff:0:0/96`.
pub const IPV4_MAPPED_PREFIX_BITS: u8 = 96;
/// Leading 96-bit pattern identifying an IPv4-mapped IPv6 address.
pub 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 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 const FORWARDED_FOR_PREFIX: &str = "for=";
/// RFC 7239 sentinel token denoting an unknown forwarded address.
pub const FORWARDED_UNKNOWN: &str = "unknown";
/// Error message returned when parsing an empty CIDR string.
pub const ERR_EMPTY_CIDR: &str = "empty CIDR specification";
/// Error message returned when the IP address part of a CIDR fails to parse.
pub const ERR_INVALID_IP: &str = "invalid IP address in CIDR";
/// Error message returned when the prefix length fails to parse as an integer.
pub const ERR_INVALID_PREFIX: &str = "invalid CIDR prefix length";
/// Error message returned when the prefix length exceeds the address family width.
pub const ERR_PREFIX_OUT_OF_RANGE: &str = "CIDR prefix length out of range";
/// ASCII digit zero byte (`0`).
pub const ASCII_ZERO: u8 = b'0';
/// ASCII dot byte (`.`).
pub const ASCII_DOT: u8 = b'.';
/// ASCII colon byte (`:`).
pub const ASCII_COLON: u8 = b':';
/// ASCII double quote byte (`"`).
pub const ASCII_QUOTE: u8 = b'"';
/// ASCII underscore byte (`_`).
pub const ASCII_UNDERSCORE: u8 = b'_';
/// ASCII opening bracket byte (`[`).
pub const ASCII_LBRACKET: u8 = b'[';
/// ASCII semicolon byte (`;`).
pub const ASCII_SEMICOLON: u8 = b';';
/// ASCII lowercase `'f'` byte for RFC 7239 `for=` matching.
pub const ASCII_LOWER_F: u8 = b'f';
/// ASCII lowercase `'o'` byte for RFC 7239 `for=` matching.
pub const ASCII_LOWER_O: u8 = b'o';
/// ASCII lowercase `'r'` byte for RFC 7239 `for=` matching.
pub const ASCII_LOWER_R: u8 = b'r';
/// ASCII equals byte (`=`).
pub const ASCII_EQUALS: u8 = b'=';
/// ASCII comma byte (`,`).
pub const ASCII_COMMA: u8 = b',';
/// ASCII forward-slash byte (`/`).
pub const ASCII_SLASH: u8 = b'/';