pub struct IPDiversityConfig {
pub max_nodes_per_64: usize,
pub max_nodes_per_48: usize,
pub max_nodes_per_32: usize,
pub max_nodes_per_ipv4_32: usize,
pub max_nodes_per_ipv4_24: usize,
pub max_nodes_per_ipv4_16: usize,
pub max_per_ip_cap: usize,
pub max_network_fraction: f64,
pub max_nodes_per_asn: usize,
pub enable_geolocation_check: bool,
pub min_geographic_diversity: usize,
}Expand description
Configuration for IP diversity enforcement at multiple subnet levels
Fields§
§max_nodes_per_64: usizeMaximum nodes per /64 subnet (default: 1)
max_nodes_per_48: usizeMaximum nodes per /48 allocation (default: 3)
max_nodes_per_32: usizeMaximum nodes per /32 region (default: 10)
max_nodes_per_ipv4_32: usizeMaximum nodes per single IPv4 address (/32) - dynamic by default
max_nodes_per_ipv4_24: usizeMaximum nodes per /24 subnet (Class C) - default: 3x per-IP
max_nodes_per_ipv4_16: usizeMaximum nodes per /16 subnet (Class B) - default: 10x per-IP
max_per_ip_cap: usizeAbsolute maximum nodes allowed per single IP (default: 50)
max_network_fraction: f64Maximum fraction of network any single IP can represent (default: 0.005 = 0.5%)
max_nodes_per_asn: usizeMaximum nodes per AS number (default: 20)
enable_geolocation_check: boolEnable GeoIP-based diversity checks
min_geographic_diversity: usizeMinimum number of different countries required
Implementations§
Source§impl IPDiversityConfig
impl IPDiversityConfig
Sourcepub fn testnet() -> Self
pub fn testnet() -> Self
Create a testnet configuration with relaxed diversity requirements.
This is useful for testing environments like Digital Ocean where all nodes share the same ASN (AS14061). The relaxed limits allow many nodes from the same provider while still maintaining some diversity tracking.
§Warning
This configuration should NEVER be used in production as it significantly weakens Sybil attack protection.
Sourcepub fn permissive() -> Self
pub fn permissive() -> Self
Create a permissive configuration that effectively disables diversity checks.
This is useful for local development and unit testing where all nodes run on localhost or the same machine.
Sourcepub fn is_relaxed(&self) -> bool
pub fn is_relaxed(&self) -> bool
Check if this is a testnet or permissive configuration.
Trait Implementations§
Source§impl Clone for IPDiversityConfig
impl Clone for IPDiversityConfig
Source§fn clone(&self) -> IPDiversityConfig
fn clone(&self) -> IPDiversityConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for IPDiversityConfig
impl Debug for IPDiversityConfig
Source§impl Default for IPDiversityConfig
impl Default for IPDiversityConfig
Source§impl<'de> Deserialize<'de> for IPDiversityConfig
impl<'de> Deserialize<'de> for IPDiversityConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for IPDiversityConfig
impl RefUnwindSafe for IPDiversityConfig
impl Send for IPDiversityConfig
impl Sync for IPDiversityConfig
impl Unpin for IPDiversityConfig
impl UnsafeUnpin for IPDiversityConfig
impl UnwindSafe for IPDiversityConfig
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.