pub struct RelayManager { /* private fields */ }Expand description
Manages relay connections for NAT traversal fallback
Implementations§
Source§impl RelayManager
impl RelayManager
Sourcepub fn new(config: RelayManagerConfig) -> Self
pub fn new(config: RelayManagerConfig) -> Self
Create a new relay manager
Sourcepub fn stats(&self) -> Arc<RelayManagerStats>
pub fn stats(&self) -> Arc<RelayManagerStats>
Get statistics
Sourcepub async fn add_relay_node(&self, address: SocketAddr)
pub async fn add_relay_node(&self, address: SocketAddr)
Add a potential relay node
Sourcepub async fn remove_relay_node(&self, address: SocketAddr)
pub async fn remove_relay_node(&self, address: SocketAddr)
Remove a relay node
Sourcepub async fn available_relays(&self) -> Vec<SocketAddr>
pub async fn available_relays(&self) -> Vec<SocketAddr>
Get list of available relay addresses
Sourcepub async fn get_relay_client(&self, relay: SocketAddr) -> Option<SocketAddr>
pub async fn get_relay_client(&self, relay: SocketAddr) -> Option<SocketAddr>
Get a connected relay client for a specific relay
Sourcepub fn create_connect_request(&self) -> ConnectUdpRequest
pub fn create_connect_request(&self) -> ConnectUdpRequest
Initiate relay connection (returns request to send)
Sourcepub async fn handle_connect_response(
&self,
relay: SocketAddr,
response: ConnectUdpResponse,
) -> RelayResult<Option<SocketAddr>>
pub async fn handle_connect_response( &self, relay: SocketAddr, response: ConnectUdpResponse, ) -> RelayResult<Option<SocketAddr>>
Handle relay connection response
Sourcepub async fn public_address(&self) -> Option<SocketAddr>
pub async fn public_address(&self) -> Option<SocketAddr>
Get our public address from any connected relay
Sourcepub async fn send_via_relay(
&self,
relay: SocketAddr,
target: SocketAddr,
payload: Bytes,
) -> RelayResult<()>
pub async fn send_via_relay( &self, relay: SocketAddr, target: SocketAddr, payload: Bytes, ) -> RelayResult<()>
Send datagram through relay
Sourcepub async fn active_relay_count(&self) -> usize
pub async fn active_relay_count(&self) -> usize
Get number of active relay connections
Sourcepub async fn has_available_relay(&self) -> bool
pub async fn has_available_relay(&self) -> bool
Check if relay fallback is available
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RelayManager
impl !RefUnwindSafe for RelayManager
impl Send for RelayManager
impl Sync for RelayManager
impl Unpin for RelayManager
impl !UnwindSafe for RelayManager
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