pub struct NatTraversalEndpoint { /* private fields */ }Expand description
High-level NAT traversal endpoint for Autonomi P2P networks
Implementations§
Source§impl NatTraversalEndpoint
impl NatTraversalEndpoint
Sourcepub async fn new(
config: NatTraversalConfig,
event_callback: Option<Box<dyn Fn(NatTraversalEvent) + Send + Sync>>,
) -> Result<Self, NatTraversalError>
pub async fn new( config: NatTraversalConfig, event_callback: Option<Box<dyn Fn(NatTraversalEvent) + Send + Sync>>, ) -> Result<Self, NatTraversalError>
Create a new NAT traversal endpoint with optional event callback
Sourcepub fn initiate_nat_traversal(
&self,
peer_id: PeerId,
coordinator: SocketAddr,
) -> Result<(), NatTraversalError>
pub fn initiate_nat_traversal( &self, peer_id: PeerId, coordinator: SocketAddr, ) -> Result<(), NatTraversalError>
Initiate NAT traversal to a peer (returns immediately, progress via events)
Sourcepub fn get_statistics(
&self,
) -> Result<NatTraversalStatistics, NatTraversalError>
pub fn get_statistics( &self, ) -> Result<NatTraversalStatistics, NatTraversalError>
Get current NAT traversal statistics
Sourcepub fn add_bootstrap_node(
&self,
address: SocketAddr,
) -> Result<(), NatTraversalError>
pub fn add_bootstrap_node( &self, address: SocketAddr, ) -> Result<(), NatTraversalError>
Add a new bootstrap node
Sourcepub fn remove_bootstrap_node(
&self,
address: SocketAddr,
) -> Result<(), NatTraversalError>
pub fn remove_bootstrap_node( &self, address: SocketAddr, ) -> Result<(), NatTraversalError>
Remove a bootstrap node
Sourcepub async fn start_listening(
&self,
bind_addr: SocketAddr,
) -> Result<(), NatTraversalError>
pub async fn start_listening( &self, bind_addr: SocketAddr, ) -> Result<(), NatTraversalError>
Start listening for incoming connections (async version)
Sourcepub async fn connect_to_peer(
&self,
peer_id: PeerId,
server_name: &str,
remote_addr: SocketAddr,
) -> Result<QuinnConnection, NatTraversalError>
pub async fn connect_to_peer( &self, peer_id: PeerId, server_name: &str, remote_addr: SocketAddr, ) -> Result<QuinnConnection, NatTraversalError>
Connect to a peer using NAT traversal
Sourcepub async fn accept_connection(
&self,
) -> Result<(PeerId, QuinnConnection), NatTraversalError>
pub async fn accept_connection( &self, ) -> Result<(PeerId, QuinnConnection), NatTraversalError>
Accept incoming connections on the endpoint
Sourcepub fn local_peer_id(&self) -> PeerId
pub fn local_peer_id(&self) -> PeerId
Get the local peer ID
Sourcepub fn get_connection(
&self,
peer_id: &PeerId,
) -> Result<Option<QuinnConnection>, NatTraversalError>
pub fn get_connection( &self, peer_id: &PeerId, ) -> Result<Option<QuinnConnection>, NatTraversalError>
Get an active connection by peer ID
Sourcepub fn remove_connection(
&self,
peer_id: &PeerId,
) -> Result<Option<QuinnConnection>, NatTraversalError>
pub fn remove_connection( &self, peer_id: &PeerId, ) -> Result<Option<QuinnConnection>, NatTraversalError>
Remove a connection by peer ID
Sourcepub fn list_connections(
&self,
) -> Result<Vec<(PeerId, SocketAddr)>, NatTraversalError>
pub fn list_connections( &self, ) -> Result<Vec<(PeerId, SocketAddr)>, NatTraversalError>
List all active connections
Sourcepub async fn handle_connection_data(
&self,
peer_id: PeerId,
connection: &QuinnConnection,
) -> Result<(), NatTraversalError>
pub async fn handle_connection_data( &self, peer_id: PeerId, connection: &QuinnConnection, ) -> Result<(), NatTraversalError>
Handle incoming data from a connection
Sourcepub async fn shutdown(&self) -> Result<(), NatTraversalError>
pub async fn shutdown(&self) -> Result<(), NatTraversalError>
Shutdown the endpoint
Sourcepub async fn discover_candidates(
&self,
peer_id: PeerId,
) -> Result<Vec<CandidateAddress>, NatTraversalError>
pub async fn discover_candidates( &self, peer_id: PeerId, ) -> Result<Vec<CandidateAddress>, NatTraversalError>
Discover address candidates for a peer
Sourcepub fn poll(
&self,
now: Instant,
) -> Result<Vec<NatTraversalEvent>, NatTraversalError>
pub fn poll( &self, now: Instant, ) -> Result<Vec<NatTraversalEvent>, NatTraversalError>
Poll for NAT traversal progress and state machine updates
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NatTraversalEndpoint
impl !RefUnwindSafe for NatTraversalEndpoint
impl Send for NatTraversalEndpoint
impl Sync for NatTraversalEndpoint
impl Unpin for NatTraversalEndpoint
impl !UnwindSafe for NatTraversalEndpoint
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