pub struct BanList { /* private fields */ }
Expand description
Stores peers that should be taken out of circulation either indefinitely or until a certain timestamp
Implementations§
Source§impl BanList
impl BanList
Sourcepub fn new(
banned_peers: impl IntoIterator<Item = B512>,
banned_ips: impl IntoIterator<Item = IpAddr>,
) -> Self
pub fn new( banned_peers: impl IntoIterator<Item = B512>, banned_ips: impl IntoIterator<Item = IpAddr>, ) -> Self
Creates a new ban list that bans the given peers and ips indefinitely.
Sourcepub const fn new_with_timeout(
banned_peers: HashMap<B512, Option<Instant>>,
banned_ips: HashMap<IpAddr, Option<Instant>>,
) -> Self
pub const fn new_with_timeout( banned_peers: HashMap<B512, Option<Instant>>, banned_ips: HashMap<IpAddr, Option<Instant>>, ) -> Self
Creates a new ban list that bans the given peers and ips with an optional timeout.
Sourcepub fn evict_peers(&mut self, now: Instant) -> Vec<B512>
pub fn evict_peers(&mut self, now: Instant) -> Vec<B512>
Removes all peers that are no longer banned.
Sourcepub fn evict_ips(&mut self, now: Instant) -> Vec<IpAddr>
pub fn evict_ips(&mut self, now: Instant) -> Vec<IpAddr>
Removes all ip addresses that are no longer banned.
Sourcepub fn evict(&mut self, now: Instant) -> (Vec<IpAddr>, Vec<B512>)
pub fn evict(&mut self, now: Instant) -> (Vec<IpAddr>, Vec<B512>)
Removes all entries that should no longer be banned.
Returns the evicted entries.
Sourcepub fn is_banned(&self, peer_id: &B512, ip: &IpAddr) -> bool
pub fn is_banned(&self, peer_id: &B512, ip: &IpAddr) -> bool
Returns true if either the given peer id or ip address is banned.
Sourcepub fn is_banned_ip(&self, ip: &IpAddr) -> bool
pub fn is_banned_ip(&self, ip: &IpAddr) -> bool
checks the ban list to see if it contains the given ip
Sourcepub fn is_banned_peer(&self, peer_id: &B512) -> bool
pub fn is_banned_peer(&self, peer_id: &B512) -> bool
checks the ban list to see if it contains the given ip
Sourcepub fn unban_peer(&mut self, peer_id: &B512)
pub fn unban_peer(&mut self, peer_id: &B512)
Unbans the ip address
Sourcepub fn ban_ip_until(&mut self, ip: IpAddr, until: Instant)
pub fn ban_ip_until(&mut self, ip: IpAddr, until: Instant)
Bans the IP until the timestamp.
This does not ban non-global IPs.
Sourcepub fn ban_peer_until(&mut self, node_id: B512, until: Instant)
pub fn ban_peer_until(&mut self, node_id: B512, until: Instant)
Bans the peer until the timestamp
Sourcepub fn ban_ip(&mut self, ip: IpAddr)
pub fn ban_ip(&mut self, ip: IpAddr)
Bans the IP indefinitely.
This does not ban non-global IPs.
Sourcepub fn ban_peer_with(&mut self, node_id: B512, until: Option<Instant>)
pub fn ban_peer_with(&mut self, node_id: B512, until: Option<Instant>)
Bans the peer indefinitely or until the given timeout.
Sourcepub fn ban_ip_with(&mut self, ip: IpAddr, until: Option<Instant>)
pub fn ban_ip_with(&mut self, ip: IpAddr, until: Option<Instant>)
Bans the ip indefinitely or until the given timeout.
This does not ban non-global IPs.
Trait Implementations§
impl Eq for BanList
impl StructuralPartialEq for BanList
Auto Trait Implementations§
impl Freeze for BanList
impl RefUnwindSafe for BanList
impl Send for BanList
impl Sync for BanList
impl Unpin for BanList
impl UnwindSafe for BanList
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 96 bytes