NatTraversalEndpoint

Struct NatTraversalEndpoint 

Source
pub struct NatTraversalEndpoint { /* private fields */ }
Expand description

High-level NAT traversal endpoint for Autonomi P2P networks

Implementations§

Source§

impl NatTraversalEndpoint

Source

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

Source

pub fn get_quinn_endpoint(&self) -> Option<&Endpoint>

Get the underlying Quinn endpoint

Source

pub fn get_event_callback( &self, ) -> Option<&Box<dyn Fn(NatTraversalEvent) + Send + Sync>>

Get the event callback

Source

pub fn initiate_nat_traversal( &self, peer_id: PeerId, coordinator: SocketAddr, ) -> Result<(), NatTraversalError>

Initiate NAT traversal to a peer (returns immediately, progress via events)

Source

pub fn poll_sessions( &self, ) -> Result<Vec<SessionStateUpdate>, NatTraversalError>

Poll all active sessions and update their states

Source

pub fn start_session_polling(&self, interval: Duration) -> JoinHandle<()>

Start periodic session polling task

Source

pub fn get_statistics( &self, ) -> Result<NatTraversalStatistics, NatTraversalError>

Get current NAT traversal statistics

Source

pub fn add_bootstrap_node( &self, address: SocketAddr, ) -> Result<(), NatTraversalError>

Add a new bootstrap node

Source

pub fn remove_bootstrap_node( &self, address: SocketAddr, ) -> Result<(), NatTraversalError>

Remove a bootstrap node

Source

pub async fn start_listening( &self, bind_addr: SocketAddr, ) -> Result<(), NatTraversalError>

Start listening for incoming connections (async version)

Source

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

Source

pub async fn accept_connection( &self, ) -> Result<(PeerId, QuinnConnection), NatTraversalError>

Accept incoming connections on the endpoint

Source

pub fn local_peer_id(&self) -> PeerId

Get the local peer ID

Source

pub fn get_connection( &self, peer_id: &PeerId, ) -> Result<Option<QuinnConnection>, NatTraversalError>

Get an active connection by peer ID

Source

pub fn remove_connection( &self, peer_id: &PeerId, ) -> Result<Option<QuinnConnection>, NatTraversalError>

Remove a connection by peer ID

Source

pub fn list_connections( &self, ) -> Result<Vec<(PeerId, SocketAddr)>, NatTraversalError>

List all active connections

Source

pub async fn handle_connection_data( &self, peer_id: PeerId, connection: &QuinnConnection, ) -> Result<(), NatTraversalError>

Handle incoming data from a connection

Source

pub async fn shutdown(&self) -> Result<(), NatTraversalError>

Shutdown the endpoint

Source

pub async fn discover_candidates( &self, peer_id: PeerId, ) -> Result<Vec<CandidateAddress>, NatTraversalError>

Discover address candidates for a peer

Source

pub fn poll( &self, now: Instant, ) -> Result<Vec<NatTraversalEvent>, NatTraversalError>

Poll for NAT traversal progress and state machine updates

Source

pub fn get_nat_stats( &self, ) -> Result<NatTraversalStatistics, Box<dyn Error + Send + Sync>>

Get NAT traversal statistics

Trait Implementations§

Source§

impl Debug for NatTraversalEndpoint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more