pub struct ConnectionPolicy {
pub name: String,
pub action: PolicyAction,
pub priority: u32,
pub peer_whitelist: Vec<String>,
pub peer_blacklist: Vec<String>,
pub max_connections_per_peer: Option<usize>,
pub rate_limit: Option<f64>,
pub enabled: bool,
}Expand description
Connection policy for controlling peer connections
Fields§
§name: StringPolicy name
action: PolicyActionAction to take
priority: u32Priority (higher = evaluated first)
peer_whitelist: Vec<String>Peer whitelist (empty = all allowed)
peer_blacklist: Vec<String>Peer blacklist
max_connections_per_peer: Option<usize>Maximum connections per peer
rate_limit: Option<f64>Connection rate limit (connections per second)
enabled: boolEnabled
Implementations§
Source§impl ConnectionPolicy
impl ConnectionPolicy
Sourcepub fn with_action(self, action: PolicyAction) -> Self
pub fn with_action(self, action: PolicyAction) -> Self
Set the action
Sourcepub fn with_priority(self, priority: u32) -> Self
pub fn with_priority(self, priority: u32) -> Self
Set the priority
Sourcepub fn with_whitelist_peer(self, peer: impl Into<String>) -> Self
pub fn with_whitelist_peer(self, peer: impl Into<String>) -> Self
Add peer to whitelist
Sourcepub fn with_blacklist_peer(self, peer: impl Into<String>) -> Self
pub fn with_blacklist_peer(self, peer: impl Into<String>) -> Self
Add peer to blacklist
Sourcepub fn with_max_connections(self, max: usize) -> Self
pub fn with_max_connections(self, max: usize) -> Self
Set max connections per peer
Sourcepub fn with_rate_limit(self, rate: f64) -> Self
pub fn with_rate_limit(self, rate: f64) -> Self
Set rate limit
Sourcepub fn evaluate(&self, peer_id: &str) -> Option<PolicyResult>
pub fn evaluate(&self, peer_id: &str) -> Option<PolicyResult>
Evaluate if this policy matches
Trait Implementations§
Source§impl Clone for ConnectionPolicy
impl Clone for ConnectionPolicy
Source§fn clone(&self) -> ConnectionPolicy
fn clone(&self) -> ConnectionPolicy
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ConnectionPolicy
impl RefUnwindSafe for ConnectionPolicy
impl Send for ConnectionPolicy
impl Sync for ConnectionPolicy
impl Unpin for ConnectionPolicy
impl UnwindSafe for ConnectionPolicy
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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