Expand description
Network Policy Engine - Fine-grained control over network operations
This module provides a policy engine for enforcing various network policies:
- Connection policies (whitelist/blacklist, rate limits)
- Bandwidth policies (per-peer, per-protocol limits)
- Content policies (allowed CIDs, content types)
- Time-based policies (schedules, quotas)
- Geographic policies (region restrictions)
Useful for production deployments requiring fine-grained control.
§Example
use ipfrs_network::{PolicyEngine, PolicyConfig, ConnectionPolicy, PolicyAction};
let config = PolicyConfig::default();
let engine = PolicyEngine::new(config);
// Add a connection policy
let policy = ConnectionPolicy::new("block-untrusted")
.with_action(PolicyAction::Deny)
.with_priority(100);
engine.add_connection_policy(policy)?;
// Evaluate connection
let allowed = engine.evaluate_connection("peer123").await?;
println!("Connection allowed: {}", allowed);Structs§
- Bandwidth
Policy - Bandwidth policy for controlling data transfer
- Connection
Policy - Connection policy for controlling peer connections
- Content
Policy - Content policy for controlling what content is allowed
- Policy
Config - Configuration for the policy engine
- Policy
Engine - Policy engine for enforcing network policies
- Policy
Result - Policy evaluation result
- Policy
Stats - Statistics tracked by the policy engine
Enums§
- Policy
Action - Action to take when a policy matches
- Policy
Error - Errors that can occur in the policy engine