Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/src/state_filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ fn add_unary_pred(
};

let mut body: Vec<proc_macro2::TokenStream> = vec![];
gen_state_filter_util(&mut body, node, tree, statics, sub, extract_sessions);
update_body(&mut body, node, sub);
gen_state_filter_util(&mut body, node, tree, statics, sub, extract_sessions);

if first_unary {
code.push(quote! {
Expand Down Expand Up @@ -304,8 +304,8 @@ fn add_pred(
extract_sessions: bool,
) {
let mut body: Vec<proc_macro2::TokenStream> = vec![];
gen_state_filter_util(&mut body, node, tree, statics, sub, extract_sessions);
update_body(&mut body, node, sub);
gen_state_filter_util(&mut body, node, tree, statics, sub, extract_sessions);
if node.if_else {
code.push(quote! {
else if #pred_tokenstream {
Expand Down
19 changes: 18 additions & 1 deletion core/src/protocols/stream/tls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ use itertools::Itertools;
use serde::Serialize;
use tls_parser::{TlsCipherSuite, TlsState};

/// Serializes [`TlsState`] using its `Debug` representation, since the upstream `tls-parser`
/// crate does not implement `Serialize` for it.
fn serialize_state<S: serde::Serializer>(state: &TlsState, s: S) -> Result<S::Ok, S::Error> {
s.serialize_str(&format!("{:?}", state))
}

/// GREASE values. See [RFC 8701](https://datatracker.ietf.org/doc/html/rfc8701).
const GREASE_TABLE: &[u16] = &[
0x0a0a, 0x1a1a, 0x2a2a, 0x3a3a, 0x4a4a, 0x5a5a, 0x6a6a, 0x7a7a, 0x8a8a, 0x9a9a, 0xaaaa, 0xbaba,
Expand All @@ -34,7 +40,7 @@ pub struct Tls {
pub client_key_exchange: Option<ClientKeyExchange>,

/// TLS state.
#[serde(skip)]
#[serde(serialize_with = "serialize_state")]
state: TlsState,
/// TCP chunks defragmentation buffer. Defragments TCP segments that arrive over multiple
/// packets.
Expand Down Expand Up @@ -139,6 +145,17 @@ impl Tls {
}
}

/// Returns `true` if the handshake state machine encountered an invalid or out-of-order
/// message sequence.
///
/// ## Remarks
/// A handshake can still be fully parsed (e.g. a valid ClientHello/SNI) even if a later
/// message renders the overall state invalid, so this should be checked in addition to
/// inspecting the parsed handshake contents.
pub fn is_invalid(&self) -> bool {
self.state == TlsState::Invalid
}

/// Returns the name of the server the client is trying to connect to.
///
/// ## Remarks
Expand Down
Loading