tapd-0.1.1 has been yanked.
TAPD interfaces
Usage
First, add the following to your Cargo.toml:
[dependencies]
tapd = "0.1"
Example
The following example creates and configures a TAP interface and starts reading
packets from it.
use std::{env::args, io::IsTerminal};
use tapd::{pipe_std, pipe_tun};
#[tokio::main(worker_threads = 2)]
async fn main() {
let mut argv = args();
let app = argv.next().unwrap();
match argv.len() {
2 => pipe_tun(&argv.next().unwrap(), &argv.next().unwrap()).await,
1 => {
let a = std::io::stdin();
let b = std::io::stdout();
if !a.is_terminal() && !b.is_terminal() {
pipe_std(&argv.next().unwrap()).await
}
}
_ => {}
}
eprintln!("Usage: {app:?} [dev1 dev2 | dev]");
}
Linux
You will need the tun module to be loaded and root is required to create
interfaces.