Expand description
§Example:
use tun_rs::DeviceBuilder;
let dev = DeviceBuilder::new()
.name("utun7")
.ipv4("10.0.0.12", 24, None)
.ipv6("CDCD:910A:2222:5498:8475:1111:3900:2021", 64)
.mtu(1400)
.build_sync().unwrap();
let mut buf = [0;65535];
loop {
let len = dev.recv(&mut buf).unwrap();
println!("buf= {:?}",&buf[..len]);
}
§Example IOS/Android:
#[cfg(unix)]
{
use tun_rs::SyncDevice;
// use PacketTunnelProvider/VpnService create tun fd
let fd = 7799;
let dev = unsafe{SyncDevice::from_fd(fd)};
let mut buf = [0;65535];
loop {
let len = dev.recv(&mut buf).unwrap();
println!("buf= {:?}",&buf[..len]);
}
}
Re-exports§
pub use crate::platform::*;
pub use async_device::*;
async_std
orasync_tokio
Modules§
- async_
device async_std
orasync_tokio
- platform
Structs§
- Device
Builder - A builder for configuring a TUN/TAP interface.
Enums§
- Layer
- Represents the OSI layer at which the TUN interface operates.
Constants§
Traits§
- ToIpv4
Address - Trait for converting various types into an IPv4 address.
- ToIpv4
Netmask - Trait for converting various types into an IPv4 netmask (prefix length).
- ToIpv6
Address - Trait for converting various types into an IPv6 address.
- ToIpv6
Netmask - Trait for converting various types into an IPv6 netmask (prefix length).