proxy_protocol_codec/v1/
model.rs

1//! PROXY Protocol v1 header models
2
3use core::net::{Ipv4Addr, Ipv6Addr};
4
5#[cfg(feature = "feat-codec-decode")]
6use crate::v1::Header;
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
9/// The address type, which can be either an IPv4/IPv6 address or a UNIX socket
10/// address.
11pub enum AddressPair {
12    /// Unknown
13    Unspecified,
14
15    /// The address is an IPv4 address.
16    Inet {
17        /// SRC IPv4 address.
18        src_ip: Ipv4Addr,
19
20        /// DST IPv4 address.
21        dst_ip: Ipv4Addr,
22
23        /// SRC port.
24        src_port: u16,
25
26        /// DST port.
27        dst_port: u16,
28    },
29
30    /// The address is an IPv6 address.
31    Inet6 {
32        /// SRC IPv4 address.
33        src_ip: Ipv6Addr,
34
35        /// DST IPv4 address.
36        dst_ip: Ipv6Addr,
37
38        /// SRC port.
39        src_port: u16,
40
41        /// DST port.
42        dst_port: u16,
43    },
44}
45
46#[cfg(feature = "feat-codec-decode")]
47#[derive(Debug)]
48/// The result of decoding a PROXY Protocol v1 header.
49pub enum Decoded {
50    /// The PROXY Protocol v1 header and its extensions decoded.
51    Some(Header),
52
53    /// Partial data, the caller should read more data.
54    ///
55    /// However, it's hard to determine how much more data is needed like PROXY
56    /// Protocol v2.
57    Partial,
58
59    /// Not a PROXY Protocol v1 header.
60    None,
61}