pub struct WireGuardTunnel { /* private fields */ }Expand description
A WireGuard tunnel that encrypts/decrypts IP packets.
Implementations§
Source§impl WireGuardTunnel
impl WireGuardTunnel
Sourcepub async fn new(config: WireGuardConfig) -> Result<Arc<Self>>
pub async fn new(config: WireGuardConfig) -> Result<Arc<Self>>
Create a new WireGuard tunnel with the given configuration.
Sourcepub fn outgoing_sender(&self) -> Sender<BytesMut>
pub fn outgoing_sender(&self) -> Sender<BytesMut>
Get the sender for outgoing packets.
Sourcepub fn take_incoming_receiver(&self) -> Option<Receiver<BytesMut>>
pub fn take_incoming_receiver(&self) -> Option<Receiver<BytesMut>>
Get the receiver for incoming packets (takes ownership of the receiver).
Sourcepub async fn initiate_handshake(&self) -> Result<()>
pub async fn initiate_handshake(&self) -> Result<()>
Initiate the WireGuard handshake.
Sourcepub async fn send_ip_packet(&self, packet: BytesMut) -> Result<()>
pub async fn send_ip_packet(&self, packet: BytesMut) -> Result<()>
Send an IP packet through the tunnel (encrypts and sends via UDP).
Sourcepub async fn run_receive_loop(self: &Arc<Self>) -> Result<()>
pub async fn run_receive_loop(self: &Arc<Self>) -> Result<()>
Run the tunnel’s receive loop (listens for UDP packets and decrypts them).
Sourcepub async fn run_send_loop(self: &Arc<Self>) -> Result<()>
pub async fn run_send_loop(self: &Arc<Self>) -> Result<()>
Run the tunnel’s send loop (encrypts and sends IP packets).
Sourcepub async fn run_timer_loop(self: &Arc<Self>) -> Result<()>
pub async fn run_timer_loop(self: &Arc<Self>) -> Result<()>
Run the tunnel’s timer loop (handles keepalives and handshake retries).
Sourcepub async fn wait_for_handshake(&self, timeout_duration: Duration) -> Result<()>
pub async fn wait_for_handshake(&self, timeout_duration: Duration) -> Result<()>
Wait for the handshake to complete (with timeout).
Auto Trait Implementations§
impl !Freeze for WireGuardTunnel
impl !RefUnwindSafe for WireGuardTunnel
impl Send for WireGuardTunnel
impl Sync for WireGuardTunnel
impl Unpin for WireGuardTunnel
impl !UnwindSafe for WireGuardTunnel
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§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> 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