pub struct SnapTunEndpoint { /* private fields */ }Expand description
Snap tunnel endpoint that allows creating new snap tun connections. It holds one static identity and manages the registration of this identity with all connected control planes.
The data plane binds a tunnel to the socket address that the endpoint sends from and to the static identity of the endpoint. Two rules follow for an application that reconnects:
- Reuse the static identity if you reuse the socket address. Store the identity and pass it to SnapTunEndpoint::new again. The data plane then accepts the handshake at once and gives the endpoint a new tunnel session.
- Use a new socket address if you start with a new static identity. On the old address the data plane answers no handshake, and it drops the packets of the new identity, until the tunnel of the old identity expires. That takes several minutes.
An application that lets the socket address and the static identity change together is always correct. An application that pins its port must also pin its identity. SnapTunServer documents why the data plane holds an address for one identity.
Implementations§
Source§impl SnapTunEndpoint
impl SnapTunEndpoint
Sourcepub fn new(
token_source: Arc<dyn TokenSource>,
static_private: StaticSecret,
) -> Self
pub fn new( token_source: Arc<dyn TokenSource>, static_private: StaticSecret, ) -> Self
Creates a new SNAP tunnel socket manager.
Sourcepub async fn connect_tunnel(
&self,
peer_public: PublicKey,
dataplane_address: SocketAddr,
control_plane: Url,
control_plane_client: Arc<dyn SnapTunControlPlaneClient>,
underlay_socket: Arc<UdpSocket>,
receive_queue_capacity: usize,
pool: PacketBufPool<PACKET_BUF_POOL_SIZE>,
) -> Result<SnapTunnel, ConnectSnapTunSocketError>
pub async fn connect_tunnel( &self, peer_public: PublicKey, dataplane_address: SocketAddr, control_plane: Url, control_plane_client: Arc<dyn SnapTunControlPlaneClient>, underlay_socket: Arc<UdpSocket>, receive_queue_capacity: usize, pool: PacketBufPool<PACKET_BUF_POOL_SIZE>, ) -> Result<SnapTunnel, ConnectSnapTunSocketError>
Connects a new SNAP tunnel. If the endpoints static identity is not already registered with the selected snap-tun control plane, it is registered before this method returns.
Trait Implementations§
Source§impl Drop for SnapTunEndpoint
impl Drop for SnapTunEndpoint
Auto Trait Implementations§
impl Freeze for SnapTunEndpoint
impl RefUnwindSafe for SnapTunEndpoint
impl Send for SnapTunEndpoint
impl Sync for SnapTunEndpoint
impl Unpin for SnapTunEndpoint
impl UnsafeUnpin for SnapTunEndpoint
impl UnwindSafe for SnapTunEndpoint
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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> ⓘ
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