🚧 Routing!
This commit is contained in:
parent
e643d9dd41
commit
337425446b
6 changed files with 288 additions and 2 deletions
25
tun/tests/routing.rs
Normal file
25
tun/tests/routing.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
use fehler::throws;
|
||||
use std::io::Error;
|
||||
use std::net::{IpAddr, Ipv4Addr};
|
||||
use tun::routing::{Route, add_route};
|
||||
use tun::TunInterface;
|
||||
|
||||
#[test]
|
||||
#[throws]
|
||||
fn test_create() -> std::io::Result<()> {
|
||||
let tun = TunInterface::new()?;
|
||||
let name = tun.name()?;
|
||||
println!("Interface name: {name}");
|
||||
|
||||
let addr = Ipv4Addr::new(10, 0, 0, 1);
|
||||
tun.set_ipv4_addr(addr)?;
|
||||
|
||||
let dest = IpAddr::V4(Ipv4Addr::new(8, 8, 8, 8));
|
||||
|
||||
let route = Route::new(dest, 24, &tun)?;
|
||||
add_route(route)?;
|
||||
|
||||
loop {}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue