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() -> 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 more