pub struct ClientHelloBuffer { /* private fields */ }Expand description
Buffers raw TLS record bytes so the ClientHello can be parsed after the handshake.
Deferring parsing keeps fingerprint analysis out of the handshake path. The buffer may be filled incrementally when the ClientHello spans multiple reads.
Implementations§
Source§impl ClientHelloBuffer
impl ClientHelloBuffer
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty ClientHello buffer with capacity for a typical browser handshake.
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates an empty buffer with at least the requested initial capacity.
Requesting more than the default capture limit raises the limit to the requested capacity.
Sourcepub fn with_capture_limit(capture_limit: usize) -> Self
pub fn with_capture_limit(capture_limit: usize) -> Self
Creates an empty buffer with a custom maximum capture size.
Sourcepub fn with_capacity_and_limit(capacity: usize, capture_limit: usize) -> Self
pub fn with_capacity_and_limit(capacity: usize, capture_limit: usize) -> Self
Creates an empty buffer with explicit allocation and capture limits.
The effective capture limit is never smaller than the requested initial capacity.
Sourcepub fn from_bytes(bytes: impl Into<Vec<u8>>) -> Self
pub fn from_bytes(bytes: impl Into<Vec<u8>>) -> Self
Creates a buffer from captured TLS record bytes.
Passing a Vec<u8> transfers its allocation into the buffer. Slices are
copied because the parser owns bytes that may outlive the input read.
Bytes after the record that completes the ClientHello are discarded, matching
Self::extend.
Sourcepub fn parse(&self) -> Result<ClientHello, ClientHelloParseError>
pub fn parse(&self) -> Result<ClientHello, ClientHelloParseError>
Attempts to parse the first complete TLS ClientHello handshake in the buffer.
The buffer remains available after either success or failure, which is useful when inspecting malformed captures.
Sourcepub fn try_parse(&self) -> Result<Option<ClientHello>, ClientHelloParseError>
pub fn try_parse(&self) -> Result<Option<ClientHello>, ClientHelloParseError>
Parses a ClientHello once all of its TLS handshake records are complete.
Returns Ok(None) while a record or the fragmented handshake is incomplete. A complete
but malformed capture returns a ClientHelloParseError. TLS record fragmentation is
defined by
RFC 9846, Section 5.1.
Sourcepub const fn is_complete(&self) -> bool
pub const fn is_complete(&self) -> bool
Returns whether the retained records contain a complete ClientHello.
Sourcepub const fn is_invalid(&self) -> bool
pub const fn is_invalid(&self) -> bool
Returns whether incremental TLS framing encountered malformed input.
Sourcepub const fn capture_limit(&self) -> usize
pub const fn capture_limit(&self) -> usize
Returns the maximum number of TLS bytes retained for an incomplete or malformed capture.