pub struct FlowAnalyzer<K>{ /* private fields */ }analysis only.Expand description
Per-flow analysis accumulator. Generic over the flow key K.
Implementations§
Source§impl<K> FlowAnalyzer<K>
impl<K> FlowAnalyzer<K>
Sourcepub fn new(ttl: Duration) -> Self
pub fn new(ttl: Duration) -> Self
New analyzer with unbounded per-flow state expired only by
ttl (idle flows reclaimed by
evict_expired). Prefer
with_capacity in production.
Sourcepub fn with_capacity(ttl: Duration, capacity: usize) -> Self
pub fn with_capacity(ttl: Duration, capacity: usize) -> Self
New analyzer bounded to capacity concurrently-tracked
flows (LRU eviction past the cap) plus the ttl idle
expiry — the project’s bounded-memory contract.
Sourcepub fn with_ioc(self, ioc: IocSet) -> Self
pub fn with_ioc(self, ioc: IocSet) -> Self
Attach a threat-intel IocSet to screen flows against at
finalize time (SNI / DNS qnames / IPs /
JA3 / JA4). Without one, AnalyzedFlow::ioc_hits is
always empty.
Sourcepub fn observe_tls(&mut self, key: &K, hs: &TlsHandshake, ts: Timestamp)
Available on crate feature tls only.
pub fn observe_tls(&mut self, key: &K, hs: &TlsHandshake, ts: Timestamp)
tls only.Fold a completed TLS handshake into the flow’s summary.
Sourcepub fn observe_http(&mut self, key: &K, msg: &HttpMessage, ts: Timestamp)
Available on crate feature http only.
pub fn observe_http(&mut self, key: &K, msg: &HttpMessage, ts: Timestamp)
http only.Fold an HTTP message into the flow’s summary (requests
only; see L7Summary::observe_http).
Sourcepub fn observe_dns_query(&mut self, key: &K, q: &DnsQuery, ts: Timestamp)
Available on crate feature dns only.
pub fn observe_dns_query(&mut self, key: &K, q: &DnsQuery, ts: Timestamp)
dns only.Record the query names from a DNS query.
Sourcepub fn observe_dns_response(&mut self, key: &K, r: &DnsResponse, ts: Timestamp)
Available on crate feature dns only.
pub fn observe_dns_response(&mut self, key: &K, r: &DnsResponse, ts: Timestamp)
dns only.Record the query names from a DNS response.
Sourcepub fn evict_expired(&mut self, now: Timestamp)
pub fn evict_expired(&mut self, now: Timestamp)
Reclaim per-flow state for flows idle longer than the TTL —
call periodically (e.g. on a tracker tick) so flows that
end without an explicit finalize don’t
linger.
Source§impl<K> FlowAnalyzer<K>
impl<K> FlowAnalyzer<K>
Sourcepub fn finalize(&mut self, key: &K, stats: FlowStats) -> AnalyzedFlow<K>
pub fn finalize(&mut self, key: &K, stats: FlowStats) -> AnalyzedFlow<K>
Finalize a flow on its Ended event: take its accumulated
L7Summary, compute the FlowRisk and IOC hits, evict
the per-flow state, and return the enriched
AnalyzedFlow. Idempotent — a second call for the same
key sees an empty summary.
Sourcepub fn snapshot(
&self,
key: &K,
now: Timestamp,
stats: FlowStats,
) -> AnalyzedFlow<K>
pub fn snapshot( &self, key: &K, now: Timestamp, stats: FlowStats, ) -> AnalyzedFlow<K>
Compute the AnalyzedFlow for a flow without evicting
its state — a mid-flow snapshot at now. Use
finalize on the terminal event.