pub struct IPDiversityConfig {Show 15 fields
pub max_nodes_per_ipv6_64: usize,
pub max_nodes_per_ipv6_48: usize,
pub max_nodes_per_ipv6_32: usize,
pub max_nodes_per_ipv4_32: Option<usize>,
pub max_nodes_per_ipv4_24: Option<usize>,
pub max_nodes_per_ipv4_16: Option<usize>,
pub ipv4_limit_floor: Option<usize>,
pub ipv4_limit_ceiling: Option<usize>,
pub ipv6_limit_floor: Option<usize>,
pub ipv6_limit_ceiling: Option<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_ipv6_64: usizeMaximum nodes per /64 subnet (default: 1)
max_nodes_per_ipv6_48: usizeMaximum nodes per /48 allocation (default: 3)
max_nodes_per_ipv6_32: usizeMaximum nodes per /32 region (default: 10)
max_nodes_per_ipv4_32: Option<usize>Optional guaranteed minimum for nodes per single IPv4 address (/32).
When None (default), the dynamic per-IP limit is used alone.
When Some(n), the effective limit is max(n, dynamic_per_ip),
ensuring at least n nodes are allowed even when the dynamic
formula yields a lower value (e.g. during bootstrap).
max_nodes_per_ipv4_24: Option<usize>Optional guaranteed minimum for nodes per /24 subnet (Class C).
When None (default), dynamic_per_ip * 3 is used alone.
When Some(n), the effective limit is max(n, dynamic_per_ip * 3).
max_nodes_per_ipv4_16: Option<usize>Optional guaranteed minimum for nodes per /16 subnet (Class B).
When None (default), dynamic_per_ip * 10 is used alone.
When Some(n), the effective limit is max(n, dynamic_per_ip * 10).
ipv4_limit_floor: Option<usize>Optional floor for all IPv4 subnet limits. When set, the effective limit at every IPv4 prefix level (/32, /24, /16) will be at least this value, overriding the dynamic calculation and existing hard caps.
ipv4_limit_ceiling: Option<usize>Optional ceiling for all IPv4 subnet limits. When set, the effective limit at every IPv4 prefix level will be at most this value.
ipv6_limit_floor: Option<usize>Optional floor for all IPv6 subnet limits.
ipv6_limit_ceiling: Option<usize>Optional ceiling for all IPv6 subnet limits.
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() -> IPDiversityConfig
pub fn testnet() -> IPDiversityConfig
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() -> IPDiversityConfig
pub fn permissive() -> IPDiversityConfig
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§fn default() -> IPDiversityConfig
fn default() -> IPDiversityConfig
Source§impl<'de> Deserialize<'de> for IPDiversityConfig
impl<'de> Deserialize<'de> for IPDiversityConfig
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<IPDiversityConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<IPDiversityConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for IPDiversityConfig
impl Serialize for IPDiversityConfig
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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> 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