Tunio
Create TUN/TAP interfaces in cross-platform and idiomatic Rust!
Features ⭐
- Tokio support (optional).
- TUN/TAP support.
- Extensible architecture for adding other platforms later.
Short example 📜
use std::io::{Read, Write};
use tunio::traits::{DriverT, InterfaceT};
use tunio::{DefaultDriver, DefaultInterface};
fn main() {
let mut driver = DefaultDriver::new().unwrap();
let if_config = DefaultDriver::if_config_builder()
.name("iface1".to_string())
.build()
.unwrap();
let mut interface = DefaultInterface::new_up(&mut driver, if_config).unwrap();
let buf = [0u8; 4096];
let _ = interface.write(&buf);
let mut mut_buf = [0u8; 4096];
let _ = interface.read(&mut mut_buf);
}
Supported platforms 🖥️
- Windows, TUN only (using
Wintun
driver).
Wintun
driver requires a prebuilt DLL inside application folder. Please, refer to Wintun
documentation for more details.
- Linux
macOS support for utun and feth drivers is planned. Feel free to post a PR, it is always greatly appreciated 😉
Related projects 🔗
netconfig
: A high-level abstraction for gathering and changing network interface configuration.