pub struct ShadowMirrorManager { /* private fields */ }Expand description
Manager for shadow mirroring operations.
Coordinates mirror decisions, rate limiting, and async delivery to honeypots. Uses a bounded queue (semaphore) to prevent memory exhaustion from slow honeypots.
Implementations§
Source§impl ShadowMirrorManager
impl ShadowMirrorManager
Sourcepub fn new(
config: ShadowMirrorConfig,
sensor_id: String,
) -> Result<Self, ShadowMirrorError>
pub fn new( config: ShadowMirrorConfig, sensor_id: String, ) -> Result<Self, ShadowMirrorError>
Creates a new shadow mirror manager with default concurrency limit.
§Errors
Returns ShadowMirrorError::ClientCreation if the HTTP client cannot be created.
Sourcepub fn with_max_concurrent(
config: ShadowMirrorConfig,
sensor_id: String,
max_concurrent: usize,
) -> Result<Self, ShadowMirrorError>
pub fn with_max_concurrent( config: ShadowMirrorConfig, sensor_id: String, max_concurrent: usize, ) -> Result<Self, ShadowMirrorError>
Creates a new shadow mirror manager with a custom concurrency limit.
§Arguments
config- Shadow mirror configurationsensor_id- Sensor ID for payload attributionmax_concurrent- Maximum concurrent mirror operations (prevents memory exhaustion)
§Errors
Returns ShadowMirrorError::ClientCreation if the HTTP client cannot be created.
Sourcepub fn should_mirror(&self, risk_score: f32, client_ip: &str) -> bool
pub fn should_mirror(&self, risk_score: f32, client_ip: &str) -> bool
Sourcepub fn mirror_async(&self, payload: MirrorPayload) -> bool
pub fn mirror_async(&self, payload: MirrorPayload) -> bool
Sends a mirror payload asynchronously (fire-and-forget) with bounded concurrency.
Returns immediately without waiting for delivery to complete. Uses a semaphore to limit concurrent operations and prevent memory exhaustion when honeypots are slow or unresponsive. If the queue is full, the request is dropped (backpressure) rather than blocking or causing unbounded growth.
§Returns
true if the payload was queued for delivery, false if dropped due to backpressure.
Sourcepub fn create_payload(
&self,
request_id: String,
source_ip: String,
method: String,
uri: String,
site_name: String,
risk_score: f32,
matched_rules: Vec<String>,
ja4: Option<String>,
ja4h: Option<String>,
campaign_id: Option<String>,
headers: HashMap<String, String>,
body: Option<String>,
) -> MirrorPayload
pub fn create_payload( &self, request_id: String, source_ip: String, method: String, uri: String, site_name: String, risk_score: f32, matched_rules: Vec<String>, ja4: Option<String>, ja4h: Option<String>, campaign_id: Option<String>, headers: HashMap<String, String>, body: Option<String>, ) -> MirrorPayload
Creates a mirror payload from request context.
§Arguments
request_id- Unique request identifiersource_ip- Client IP addressmethod- HTTP methoduri- Request URIsite_name- Site/vhost namerisk_score- Calculated risk scorematched_rules- IDs of rules that matchedja4- Optional JA4 TLS fingerprintja4h- Optional JA4H HTTP fingerprintcampaign_id- Optional campaign correlation IDheaders- Request headers to includebody- Optional request body
Sourcepub fn cleanup(&self)
pub fn cleanup(&self)
Runs periodic cleanup of the rate limiter.
Call this from a background task at regular intervals (e.g., every 60s).
Sourcepub fn stats(&self) -> ShadowMirrorStats
pub fn stats(&self) -> ShadowMirrorStats
Returns statistics about shadow mirroring.
Sourcepub fn reset_stats(&self)
pub fn reset_stats(&self)
Resets all statistics.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Returns whether shadow mirroring is enabled.
Sourcepub fn config(&self) -> &ShadowMirrorConfig
pub fn config(&self) -> &ShadowMirrorConfig
Returns the configuration.
Auto Trait Implementations§
impl !Freeze for ShadowMirrorManager
impl !RefUnwindSafe for ShadowMirrorManager
impl Send for ShadowMirrorManager
impl Sync for ShadowMirrorManager
impl Unpin for ShadowMirrorManager
impl UnsafeUnpin for ShadowMirrorManager
impl !UnwindSafe for ShadowMirrorManager
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more