Skip to main content

ClientHelloBuffer

Struct ClientHelloBuffer 

Source
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

Source

pub fn new() -> Self

Creates an empty ClientHello buffer with capacity for a typical browser handshake.

Source

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.

Source

pub fn with_capture_limit(capture_limit: usize) -> Self

Creates an empty buffer with a custom maximum capture size.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn as_bytes(&self) -> &[u8] ⓘ

Returns the currently buffered TLS bytes.

Source

pub fn len(&self) -> usize

Returns the number of currently buffered bytes.

Source

pub fn is_empty(&self) -> bool

Returns whether no TLS bytes have been buffered yet.

Source

pub const fn is_complete(&self) -> bool

Returns whether the retained records contain a complete ClientHello.

Source

pub const fn is_invalid(&self) -> bool

Returns whether incremental TLS framing encountered malformed input.

Source

pub const fn capture_limit(&self) -> usize

Returns the maximum number of TLS bytes retained for an incomplete or malformed capture.

Source

pub fn is_full(&self) -> bool

Returns whether the configured capture limit has been reached.

Source

pub fn extend(&mut self, data: &[u8]) -> usize

Appends TLS bytes until the ClientHello completes or the capture limit is reached.

Returns the number of bytes retained from data. Bytes after the TLS record that completes the ClientHello are discarded.

Trait Implementations§

Source§

impl Clone for ClientHelloBuffer

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClientHelloBuffer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ClientHelloBuffer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<&[u8]> for ClientHelloBuffer

Source§

fn from(bytes: &[u8]) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for ClientHelloBuffer

Source§

fn from(bytes: Vec<u8>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more