pub struct RebindingState { /* private fields */ }Expand description
Per-hostname history of every distinct IP ever observed across all refresh ticks for the cell’s lifetime.
Owned by the super::ticker::TickerHandle (via the spawned task’s
internal state) so observations persist across ticks without leaking out
of the ticker’s lifetime. Reset to empty when a new cell starts.
Implementations§
Source§impl RebindingState
impl RebindingState
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty state. Callers reuse a single instance for the lifetime of the cell so prior observations persist.
Sourcepub fn hostname_count(&self) -> usize
pub fn hostname_count(&self) -> usize
Number of hostnames currently tracked. Test affordance / metrics.
Sourcepub fn history(&self, hostname: &str) -> &[String]
pub fn history(&self, hostname: &str) -> &[String]
Distinct-IP history for hostname, or empty when no observation has
been committed yet. Test affordance / introspection.
Sourcepub fn evaluate<'a>(
&self,
hostname: &str,
new_targets: &'a [String],
policy: &DnsRebindingPolicy,
) -> RebindingDecision<'a>
pub fn evaluate<'a>( &self, hostname: &str, new_targets: &'a [String], policy: &DnsRebindingPolicy, ) -> RebindingDecision<'a>
Evaluate new_targets for hostname against the per-hostname
history and the operator’s DnsRebindingPolicy.
Pure function — DOES NOT mutate state. Caller emits events from the
returned RebindingDecision, then calls Self::commit to
persist the observation (the commit takes the EFFECTIVE targets so
the history reflects what the workload actually saw).
Semantics:
novel_ips = new_targets - history[hostname]. Order preserved fromnew_targets.threshold_exceeded = history[hostname].len() + novel_ips.len()strictly greater thanpolicy.max_novel_ips_per_hostname. False when no novel IPs exist (a steady CDN with churn within the prior history is fine).allowlist_violationsis empty whenpolicy.response_ip_allowlistis empty (allowlist enforcement is strictly opt-in). Otherwise, each IP innew_targetsis checked against the parsed allowlist filtered to entries with thishostnameprefix; IPs failing all entries are violations.effective_targetsisnew_targetsverbatim whenpolicy.reject_on_rebind == false. Otherwise, allowlist violations AND over-cap novel IPs are filtered out.
Sourcepub fn commit(&mut self, hostname: &str, effective_targets: &[String])
pub fn commit(&mut self, hostname: &str, effective_targets: &[String])
Persist the current observation. Must be called AFTER the caller has emitted any threshold/rejected events so the state reflects the post-tick view.
Takes the EFFECTIVE targets (post-rejection) so the history reflects what the workload actually saw. In audit-only mode the effective targets equal the raw response, so commit is functionally equivalent to “remember everything we observed.”
Trait Implementations§
Source§impl Clone for RebindingState
impl Clone for RebindingState
Source§fn clone(&self) -> RebindingState
fn clone(&self) -> RebindingState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RebindingState
impl Debug for RebindingState
Source§impl Default for RebindingState
impl Default for RebindingState
Source§fn default() -> RebindingState
fn default() -> RebindingState
Auto Trait Implementations§
impl Freeze for RebindingState
impl RefUnwindSafe for RebindingState
impl Send for RebindingState
impl Sync for RebindingState
impl Unpin for RebindingState
impl UnsafeUnpin for RebindingState
impl UnwindSafe for RebindingState
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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