pub struct MigrationState { /* private fields */ }Available on crate feature
transport only.Expand description
Migration state tracker.
Handles:
- Address validation
- Anti-amplification limiting
- Migration rate limiting
Implementations§
Source§impl MigrationState
impl MigrationState
Sourcepub fn new(initial_address: SocketAddr) -> Self
pub fn new(initial_address: SocketAddr) -> Self
Create a new migration state with the initial address.
Sourcepub fn current_address(&self) -> SocketAddr
pub fn current_address(&self) -> SocketAddr
Get the current validated address.
Sourcepub fn on_receive(&mut self, from: SocketAddr, bytes: usize)
pub fn on_receive(&mut self, from: SocketAddr, bytes: usize)
Record bytes received from an address.
Sourcepub fn on_send(&mut self, to: SocketAddr, bytes: usize)
pub fn on_send(&mut self, to: SocketAddr, bytes: usize)
Record bytes sent to an address.
Sourcepub fn can_send(&self, to: SocketAddr, bytes: usize) -> bool
pub fn can_send(&self, to: SocketAddr, bytes: usize) -> bool
Check if we can send bytes to an unvalidated address (anti-amplification).
Sourcepub fn validate_address(&mut self, addr: SocketAddr) -> bool
pub fn validate_address(&mut self, addr: SocketAddr) -> bool
Validate an address after receiving an authenticated frame from it.
Returns true if migration to this address is allowed.
Sourcepub fn is_validated(&self, addr: SocketAddr) -> bool
pub fn is_validated(&self, addr: SocketAddr) -> bool
Check if an address is validated.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MigrationState
impl RefUnwindSafe for MigrationState
impl Send for MigrationState
impl Sync for MigrationState
impl Unpin for MigrationState
impl UnwindSafe for MigrationState
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
Mutably borrows from an owned value. Read more