pub struct SnapTunNgSocket { /* private fields */ }Expand description
A SNAP tun ng socket.
Implementations§
Source§impl SnapTunNgSocket
impl SnapTunNgSocket
Sourcepub async fn new(
static_private: StaticSecret,
peer_public: PublicKey,
underlay_socket: Arc<UdpSocket>,
dataplane_address: SocketAddr,
receive_queue_capacity: usize,
) -> Result<Self, SnapTunNgSocketError>
pub async fn new( static_private: StaticSecret, peer_public: PublicKey, underlay_socket: Arc<UdpSocket>, dataplane_address: SocketAddr, receive_queue_capacity: usize, ) -> Result<Self, SnapTunNgSocketError>
Creates a new SNAP tunnel and waits for the handshake to complete.
§Arguments
static_private- The client’s static private keypeer_public- The server’s static public key (needed for handshake)rate_limiter- Rate limiter for the tunnelunderlay_socket- UDP socket for sending/receiving packetsdataplane_address- Address of the remote serverreceive_queue_capacity- Capacity of the receive queue
Sourcepub fn try_send(&self, payload: BytesMut) -> Result<()>
pub fn try_send(&self, payload: BytesMut) -> Result<()>
Try to send a packet to the remote server. Returns error of try_send_to.
Sourcepub async fn recv(&self) -> Result<Bytes, SnapTunNgSocketError>
pub async fn recv(&self) -> Result<Bytes, SnapTunNgSocketError>
Receive a packet from the remote server.
Sourcepub fn poll_recv(
&self,
cx: &mut Context<'_>,
) -> Poll<Result<Bytes, SnapTunNgSocketError>>
pub fn poll_recv( &self, cx: &mut Context<'_>, ) -> Poll<Result<Bytes, SnapTunNgSocketError>>
Poll for a packet from the remote server.
Sourcepub fn local_addr(&self) -> SocketAddr
pub fn local_addr(&self) -> SocketAddr
Get the local socket address. Assigned by the remote server.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SnapTunNgSocket
impl !RefUnwindSafe for SnapTunNgSocket
impl Send for SnapTunNgSocket
impl Sync for SnapTunNgSocket
impl Unpin for SnapTunNgSocket
impl !UnwindSafe for SnapTunNgSocket
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more