Enum proxy_header::Tlv
source · #[non_exhaustive]pub enum Tlv<'a> {
Show 13 variants
Alpn(Cow<'a, [u8]>),
Authority(Cow<'a, str>),
Crc32c(u32),
Noop(usize),
UniqueId(Cow<'a, [u8]>),
Ssl(SslInfo<'a>),
Netns(Cow<'a, str>),
SslVersion(Cow<'a, str>),
SslCn(Cow<'a, str>),
SslCipher(Cow<'a, str>),
SslSigAlg(Cow<'a, str>),
SslKeyAlg(Cow<'a, str>),
Custom(u8, Cow<'a, [u8]>),
}
Expand description
Typed TLV (type-length-value) field
Represents the currently known types of TLV fields from the PROXY protocol specification.
Non-recognized TLV fields are represented as Tlv::Custom
.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Alpn(Cow<'a, [u8]>)
Application-Layer Protocol Negotiation (ALPN). It is a byte sequence defining the upper layer protocol in use over the connection. The most common use case will be to pass the exact copy of the ALPN extension of the Transport Layer Security (TLS) protocol as defined by RFC7301.
Authority(Cow<'a, str>)
Contains the host name value passed by the client, as an UTF8-encoded string. In case of TLS being used on the client connection, this is the exact copy of the “server_name” extension as defined by RFC3546, section 3.1, often referred to as “SNI”. There are probably other situations where an authority can be mentioned on a connection without TLS being involved at all.
Crc32c(u32)
The value of the type PP2_TYPE_CRC32C is a 32-bit number storing the CRC32c checksum of the PROXY protocol header.
When the checksum is supported by the sender after constructing the header the sender MUST:
-
initialize the checksum field to ’0’s.
-
calculate the CRC32c checksum of the PROXY header as described in RFC4960, Appendix B.
-
put the resultant value into the checksum field, and leave the rest of the bits unchanged.
If the checksum is provided as part of the PROXY header and the checksum functionality is supported by the receiver, the receiver MUST:
-
store the received CRC32c checksum value aside.
-
replace the 32 bits of the checksum field in the received PROXY header with all ’0’s and calculate a CRC32c checksum value of the whole PROXY header.
-
verify that the calculated CRC32c checksum is the same as the received CRC32c checksum. If it is not, the receiver MUST treat the TCP connection providing the header as invalid.
The default procedure for handling an invalid TCP connection is to abort it.
Noop(usize)
The TLV of this type should be ignored when parsed. The value is zero or more bytes. Can be used for data padding or alignment. Note that it can be used to align only by 3 or more bytes because a TLV can not be smaller than that.
UniqueId(Cow<'a, [u8]>)
The value of the type PP2_TYPE_UNIQUE_ID is an opaque byte sequence of up to 128 bytes generated by the upstream proxy that uniquely identifies the connection.
The unique ID can be used to easily correlate connections across multiple layers of proxies, without needing to look up IP addresses and port numbers.
Ssl(SslInfo<'a>)
SSL (TLS) information
See SslInfo
for more information.
Netns(Cow<'a, str>)
The type PP2_TYPE_NETNS defines the value as the US-ASCII string representation of the namespace’s name.
SslVersion(Cow<'a, str>)
SSL/TLS version
SslCn(Cow<'a, str>)
In all cases, the string representation (in UTF8) of the Common Name field (OID: 2.5.4.3) of the client certificate’s Distinguished Name, is appended using the TLV format and the type PP2_SUBTYPE_SSL_CN. E.g. “example.com”.
SslCipher(Cow<'a, str>)
The second level TLV PP2_SUBTYPE_SSL_CIPHER provides the US-ASCII string name of the used cipher, for example “ECDHE-RSA-AES128-GCM-SHA256”.
SslSigAlg(Cow<'a, str>)
The second level TLV PP2_SUBTYPE_SSL_SIG_ALG provides the US-ASCII string name of the algorithm used to sign the certificate presented by the frontend when the incoming connection was made over an SSL/TLS transport layer, for example “SHA256”.
SslKeyAlg(Cow<'a, str>)
The second level TLV PP2_SUBTYPE_SSL_KEY_ALG provides the US-ASCII string name of the algorithm used to generate the key of the certificate presented by the frontend when the incoming connection was made over an SSL/TLS transport layer, for example “RSA2048”.
Custom(u8, Cow<'a, [u8]>)
Unrecognized or custom TLV field
Implementations§
source§impl<'a> Tlv<'a>
impl<'a> Tlv<'a>
Trait Implementations§
impl<'a> Eq for Tlv<'a>
impl<'a> StructuralPartialEq for Tlv<'a>
Auto Trait Implementations§
impl<'a> Freeze for Tlv<'a>
impl<'a> RefUnwindSafe for Tlv<'a>
impl<'a> Send for Tlv<'a>
impl<'a> Sync for Tlv<'a>
impl<'a> Unpin for Tlv<'a>
impl<'a> UnwindSafe for Tlv<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)