mirror of
https://github.com/jmcorgan/fips.git
synced 2026-08-11 00:47:39 +00:00
Promote 27 hardcoded constants to configurable parameters
Add 9 config subsection structs (LimitsConfig, RateLimitConfig, RetryConfig, CacheConfig, DiscoveryConfig, TreeConfig, BloomConfig, SessionConfig, BuffersConfig) under node.* with serde defaults. Wire all configurable values through to consuming code: - Resource limits (max_connections, max_peers, max_links, max_pending_inbound) - Rate limiting (handshake_burst, handshake_rate, handshake_timeout_secs) - Retry/backoff (consolidate max_retries, base_interval_secs under node.retry.*, add max_backoff_secs) - Cache sizes/TTL (coord_size, coord_ttl_secs, route_size) - Discovery (ttl, timeout_secs, recent_expiry_secs) - Spanning tree (root_refresh_secs, announce_min_interval_ms, parent_switch_threshold) - Bloom filter (update_debounce_ms) - Session/data plane (default_hop_limit, pending_packets_per_dest, pending_max_destinations) - Internal buffers (packet_channel, tun_channel, dns_channel) - Network internals (base_rtt_ms, tick_interval_secs) - DNS responder TTL (dns.ttl) REPLAY_WINDOW_SIZE kept as compile-time constant (array sizing). Disable flaky test_discovery_100_nodes (run with --ignored).
This commit is contained in:
+9
-3
@@ -95,6 +95,8 @@ pub struct ActivePeer {
|
||||
ancestry: Option<TreeCoordinate>,
|
||||
|
||||
// === Tree Announce Rate Limiting ===
|
||||
/// Minimum interval between TreeAnnounce messages (milliseconds).
|
||||
tree_announce_min_interval_ms: u64,
|
||||
/// Last time we sent a TreeAnnounce to this peer (Unix milliseconds).
|
||||
last_tree_announce_sent_ms: u64,
|
||||
/// Whether a tree announce is pending (deferred due to rate limit).
|
||||
@@ -136,6 +138,7 @@ impl ActivePeer {
|
||||
current_addr: None,
|
||||
declaration: None,
|
||||
ancestry: None,
|
||||
tree_announce_min_interval_ms: 500,
|
||||
last_tree_announce_sent_ms: 0,
|
||||
pending_tree_announce: false,
|
||||
inbound_filter: None,
|
||||
@@ -190,6 +193,7 @@ impl ActivePeer {
|
||||
current_addr: Some(current_addr),
|
||||
declaration: None,
|
||||
ancestry: None,
|
||||
tree_announce_min_interval_ms: 500,
|
||||
last_tree_announce_sent_ms: 0,
|
||||
pending_tree_announce: false,
|
||||
inbound_filter: None,
|
||||
@@ -481,12 +485,14 @@ impl ActivePeer {
|
||||
|
||||
// === Tree Announce Rate Limiting ===
|
||||
|
||||
/// Minimum interval between TreeAnnounce messages to the same peer (milliseconds).
|
||||
const TREE_ANNOUNCE_MIN_INTERVAL_MS: u64 = 500;
|
||||
/// Set the minimum interval between TreeAnnounce messages (milliseconds).
|
||||
pub fn set_tree_announce_min_interval_ms(&mut self, ms: u64) {
|
||||
self.tree_announce_min_interval_ms = ms;
|
||||
}
|
||||
|
||||
/// Check if we can send a TreeAnnounce now (rate limiting).
|
||||
pub fn can_send_tree_announce(&self, now_ms: u64) -> bool {
|
||||
now_ms.saturating_sub(self.last_tree_announce_sent_ms) >= Self::TREE_ANNOUNCE_MIN_INTERVAL_MS
|
||||
now_ms.saturating_sub(self.last_tree_announce_sent_ms) >= self.tree_announce_min_interval_ms
|
||||
}
|
||||
|
||||
/// Record that we sent a TreeAnnounce to this peer.
|
||||
|
||||
Reference in New Issue
Block a user