pub struct RendGuard {
pub use_counts: HashMap<String, RendUseCount>,
pub total_use_counts: f64,
pub pickle_revision: f64,
}Expand description
Rendezvous point usage tracking for detecting statistical attacks.
Tracks usage counts for all relays used as rendezvous points and detects when a relay is being used more than expected based on its bandwidth weight.
Fields§
§use_counts: HashMap<String, RendUseCount>Usage counts per relay fingerprint.
total_use_counts: f64Total usage count across all relays.
pickle_revision: f64Version number for pickle compatibility.
Implementations§
Source§impl RendGuard
impl RendGuard
Sourcepub fn scale_counts(&mut self)
pub fn scale_counts(&mut self)
Scales all usage counts by half.
Called when total_use_counts reaches the scale threshold to prevent unbounded growth and to avoid over-counting high-uptime relays.
Sourcepub fn valid_rend_use(
&mut self,
fingerprint: &str,
config: &RendguardConfig,
) -> bool
pub fn valid_rend_use( &mut self, fingerprint: &str, config: &RendguardConfig, ) -> bool
Records a rendezvous point usage and checks for overuse.
This method should be called each time a relay is used as a rendezvous point for a hidden service circuit.
§Arguments
fingerprint- The relay’s fingerprint (40 hex characters)config- Rendguard configuration
§Returns
true if the usage is valid (not overused), false if overused.
Sourcepub fn xfer_use_counts(
&mut self,
generator: &BwWeightedGenerator,
config: &RendguardConfig,
)
pub fn xfer_use_counts( &mut self, generator: &BwWeightedGenerator, config: &RendguardConfig, )
Transfers and updates use counts on consensus change.
This method should be called when a new consensus is received.
Sourcepub fn usage_rate(&self, fingerprint: &str) -> f64
pub fn usage_rate(&self, fingerprint: &str) -> f64
Returns the usage rate for a relay as a percentage.
Sourcepub fn expected_weight(&self, fingerprint: &str) -> f64
pub fn expected_weight(&self, fingerprint: &str) -> f64
Returns the expected weight for a relay as a percentage.
Sourcepub fn is_overused(&self, fingerprint: &str, config: &RendguardConfig) -> bool
pub fn is_overused(&self, fingerprint: &str, config: &RendguardConfig) -> bool
Checks if a relay is currently overused.