pub struct MasqueRelayClient { /* private fields */ }Expand description
MASQUE Relay Client
Manages a connection to a MASQUE relay server and provides APIs for sending and receiving datagrams through the relay.
Implementations§
Source§impl MasqueRelayClient
impl MasqueRelayClient
Sourcepub fn new(relay_address: SocketAddr, config: RelayClientConfig) -> Self
pub fn new(relay_address: SocketAddr, config: RelayClientConfig) -> Self
Create a new relay client (not yet connected)
Sourcepub fn relay_address(&self) -> SocketAddr
pub fn relay_address(&self) -> SocketAddr
Get relay server address
Sourcepub async fn public_address(&self) -> Option<SocketAddr>
pub async fn public_address(&self) -> Option<SocketAddr>
Get our public address (if known)
Sourcepub async fn state(&self) -> RelayConnectionState
pub async fn state(&self) -> RelayConnectionState
Get current connection state
Sourcepub async fn is_connected(&self) -> bool
pub async fn is_connected(&self) -> bool
Check if connected
Sourcepub async fn connection_duration(&self) -> Option<Duration>
pub async fn connection_duration(&self) -> Option<Duration>
Get connection duration
Sourcepub fn stats(&self) -> Arc<RelayClientStats>
pub fn stats(&self) -> Arc<RelayClientStats>
Get statistics
Sourcepub fn create_connect_request(&self) -> ConnectUdpRequest
pub fn create_connect_request(&self) -> ConnectUdpRequest
Create a CONNECT-UDP Bind request
Sourcepub async fn handle_connect_response(
&self,
response: ConnectUdpResponse,
) -> RelayResult<()>
pub async fn handle_connect_response( &self, response: ConnectUdpResponse, ) -> RelayResult<()>
Handle the CONNECT-UDP response from the relay
Sourcepub async fn handle_capsule(
&self,
capsule: Capsule,
) -> RelayResult<Option<Capsule>>
pub async fn handle_capsule( &self, capsule: Capsule, ) -> RelayResult<Option<Capsule>>
Handle an incoming capsule from the relay
Sourcepub async fn get_or_create_context(
&self,
target: SocketAddr,
) -> RelayResult<(VarInt, Option<Capsule>)>
pub async fn get_or_create_context( &self, target: SocketAddr, ) -> RelayResult<(VarInt, Option<Capsule>)>
Get or create a context for a target address
Returns the context ID and an optional capsule to send (COMPRESSION_ASSIGN).
Sourcepub async fn create_datagram(
&self,
target: SocketAddr,
payload: Bytes,
) -> RelayResult<(Datagram, Option<Capsule>)>
pub async fn create_datagram( &self, target: SocketAddr, payload: Bytes, ) -> RelayResult<(Datagram, Option<Capsule>)>
Create a datagram for sending to a target
If a context exists and is active, returns a compressed datagram. Otherwise returns an uncompressed datagram (if allowed).
Sourcepub async fn decode_datagram(
&self,
data: &[u8],
) -> RelayResult<(SocketAddr, Bytes)>
pub async fn decode_datagram( &self, data: &[u8], ) -> RelayResult<(SocketAddr, Bytes)>
Decode an incoming datagram from the relay
Sourcepub fn record_sent(&self, bytes: usize)
pub fn record_sent(&self, bytes: usize)
Record a sent datagram
Sourcepub async fn active_contexts(&self) -> Vec<VarInt>
pub async fn active_contexts(&self) -> Vec<VarInt>
Get list of active context IDs