pub struct NatForwarder { /* private fields */ }Expand description
NAT Forwarder for routing traffic to internet Uses split reader/writer to avoid mutex starvation
Implementations§
Source§impl NatForwarder
impl NatForwarder
pub fn new( tun_name: &str, tun_addr: &str, tun_netmask: &str, network_config: VpnNetworkConfig, ) -> Result<Self>
Sourcepub async fn forward_packet(&self, packet: &[u8]) -> Result<()>
pub async fn forward_packet(&self, packet: &[u8]) -> Result<()>
Forward packet to TUN (write)
Sourcepub async fn take_writer(&self) -> Option<DeviceWriter>
pub async fn take_writer(&self) -> Option<DeviceWriter>
Take ownership of the TUN writer (for use in a dedicated writer task)
Sourcepub async fn take_reader(&self) -> Option<DeviceReader>
pub async fn take_reader(&self) -> Option<DeviceReader>
Take ownership of the TUN reader (for use in a spawned task)
Trait Implementations§
Source§impl Drop for NatForwarder
impl Drop for NatForwarder
Auto Trait Implementations§
impl !Freeze for NatForwarder
impl !RefUnwindSafe for NatForwarder
impl !UnwindSafe for NatForwarder
impl Send for NatForwarder
impl Sync for NatForwarder
impl Unpin for NatForwarder
impl UnsafeUnpin for NatForwarder
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