Commit remaining Burrow platform work

This commit is contained in:
Conrad Kramer 2026-03-31 23:35:36 -07:00
parent fff5475914
commit 7f280c08cf
48 changed files with 2508 additions and 1864 deletions

View file

@ -1,10 +1,27 @@
#[cfg(all(feature = "tokio", not(target_os = "windows")))]
use std::net::Ipv4Addr;
#[cfg(all(feature = "tokio", not(target_os = "windows")))]
fn open_tun() -> Option<tun::TunInterface> {
match tun::TunInterface::new() {
Ok(tun) => Some(tun),
Err(err)
if err.kind() == std::io::ErrorKind::PermissionDenied
|| matches!(err.raw_os_error(), Some(1 | 13)) =>
{
eprintln!("skipping tokio tun test without tunnel privileges: {err}");
None
}
Err(err) => panic!("failed to create tun interface: {err}"),
}
}
#[tokio::test]
#[cfg(all(feature = "tokio", not(target_os = "windows")))]
async fn test_create() {
let tun = tun::TunInterface::new().unwrap();
let Some(tun) = open_tun() else {
return;
};
let _ = tun::tokio::TunInterface::new(tun).unwrap();
}
@ -12,7 +29,9 @@ async fn test_create() {
#[ignore = "requires interactivity"]
#[cfg(all(feature = "tokio", not(target_os = "windows")))]
async fn test_write() {
let tun = tun::TunInterface::new().unwrap();
let Some(tun) = open_tun() else {
return;
};
tun.set_ipv4_addr(Ipv4Addr::from([192, 168, 1, 10]))
.unwrap();
let async_tun = tun::tokio::TunInterface::new(tun).unwrap();