From af535d771c682f225ab0b4867a333bbcf835abac Mon Sep 17 00:00:00 2001 From: SajjadPourali Date: Sun, 1 Dec 2024 12:52:33 -0500 Subject: [PATCH 1/4] update dependencies --- Cargo.toml | 14 +++++--------- examples/tun2.rs | 6 +++--- examples/tun_wintun.rs | 4 ++-- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9e8a6a1..4089df3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,15 +11,15 @@ readme = "README.md" [dependencies] ahash = "0.8" -tokio = { version = "1.39", features = [ +tokio = { version = "1.41", features = [ "sync", "rt", "time", "io-util", "macros", ], default-features = false } -etherparse = { version = "0.15", default-features = false, features = ["std"] } -thiserror = { version = "1.0", default-features = false } +etherparse = { version = "0.16", default-features = false, features = ["std"] } +thiserror = { version = "2.0", default-features = false } log = { version = "0.4", default-features = false } rand = { version = "0.8.5", default-features = false, features = [ "std", @@ -27,7 +27,7 @@ rand = { version = "0.8.5", default-features = false, features = [ ] } [dev-dependencies] -tokio = { version = "1.39", features = [ +tokio = { version = "1.41", features = [ "rt-multi-thread", ], default-features = false } clap = { version = "4.5", features = ["derive"] } @@ -37,12 +37,8 @@ udp-stream = { version = "0.0", default-features = false } # Benchmarks criterion = { version = "0.5" } -#tun2.rs example -tun2 = { version = "2.0", features = ["async"] } - -#tun_wintun.rs example [target.'cfg(any(target_os = "linux", target_os = "macos"))'.dev-dependencies] -tun = { version = "0.6.1", features = ["async"], default-features = false } +tun = { version = "0.7.5", features = ["async"], default-features = false } [target.'cfg(target_os = "windows")'.dev-dependencies] wintun = { version = "0.5", default-features = false } diff --git a/examples/tun2.rs b/examples/tun2.rs index d3e54ea..e406203 100644 --- a/examples/tun2.rs +++ b/examples/tun2.rs @@ -5,7 +5,7 @@ //! //! This example must be run as root or administrator privileges. //! ``` -//! sudo target/debug/examples/tun2 --server-addr 127.0.0.1:8080 # Linux or macOS +//! sudo target/debug/examples/tun --server-addr 127.0.0.1:8080 # Linux or macOS //! ``` //! Then please run the `echo` example server, which listens on TCP & UDP ports 127.0.0.1:8080. //! ``` @@ -81,7 +81,7 @@ async fn main() -> Result<(), Box> { #[cfg(not(target_os = "windows"))] let gateway = Ipv4Addr::new(10, 0, 0, 1); - let mut tun_config = tun2::Configuration::default(); + let mut tun_config = tun::Configuration::default(); tun_config.address(ipv4).netmask(netmask).mtu(MTU).up(); #[cfg(not(target_os = "windows"))] tun_config.destination(gateway); // avoid routing all traffic to tun on Windows platform @@ -101,7 +101,7 @@ async fn main() -> Result<(), Box> { ipstack_config.tcp_timeout(std::time::Duration::from_secs(args.tcp_timeout)); ipstack_config.udp_timeout(std::time::Duration::from_secs(args.udp_timeout)); - let mut ip_stack = ipstack::IpStack::new(ipstack_config, tun2::create_as_async(&tun_config)?); + let mut ip_stack = ipstack::IpStack::new(ipstack_config, tun::create_as_async(&tun_config)?); let server_addr = args.server_addr; diff --git a/examples/tun_wintun.rs b/examples/tun_wintun.rs index 5ef0f38..5db5f4d 100644 --- a/examples/tun_wintun.rs +++ b/examples/tun_wintun.rs @@ -7,7 +7,7 @@ use tokio::net::TcpStream; use udp_stream::UdpStream; // const MTU: u16 = 1500; -const MTU: i32 = u16::MAX as i32; +const MTU: u16 = u16::MAX; #[derive(Parser)] #[command(author, version, about = "Testing app for tun.", long_about = None)] @@ -39,7 +39,7 @@ async fn main() -> Result<(), Box> { }); let mut ipstack_config = ipstack::IpStackConfig::default(); - ipstack_config.mtu(MTU as u16); + ipstack_config.mtu(MTU); ipstack_config.packet_information(cfg!(target_family = "unix")); #[cfg(not(target_os = "windows"))] From 5d299775bc02fd076992df4574d832042047cb4d Mon Sep 17 00:00:00 2001 From: SajjadPourali Date: Sun, 1 Dec 2024 12:54:48 -0500 Subject: [PATCH 2/4] Fix clippy issue --- examples/tun_wintun.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tun_wintun.rs b/examples/tun_wintun.rs index 5db5f4d..07002a6 100644 --- a/examples/tun_wintun.rs +++ b/examples/tun_wintun.rs @@ -34,7 +34,7 @@ async fn main() -> Result<(), Box> { config.destination(_gateway); #[cfg(target_os = "linux")] - config.platform(|config| { + config.platform_config(|config| { config.packet_information(true); }); From 2934d870d2d6145c59af008dc2ce91962d26322b Mon Sep 17 00:00:00 2001 From: SajjadPourali Date: Sun, 1 Dec 2024 12:58:58 -0500 Subject: [PATCH 3/4] Remove use of packet_information --- examples/tun_wintun.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tun_wintun.rs b/examples/tun_wintun.rs index 07002a6..5604986 100644 --- a/examples/tun_wintun.rs +++ b/examples/tun_wintun.rs @@ -40,7 +40,7 @@ async fn main() -> Result<(), Box> { let mut ipstack_config = ipstack::IpStackConfig::default(); ipstack_config.mtu(MTU); - ipstack_config.packet_information(cfg!(target_family = "unix")); + // ipstack_config.packet_information(cfg!(target_family = "unix")); #[cfg(not(target_os = "windows"))] let mut ip_stack = ipstack::IpStack::new(ipstack_config, tun::create_as_async(&config)?); From 919a4866c2c8f2326f1ef5c6c9a1a97c961a04f0 Mon Sep 17 00:00:00 2001 From: SajjadPourali Date: Sun, 1 Dec 2024 13:00:44 -0500 Subject: [PATCH 4/4] Remove use of packet_information --- examples/tun_wintun.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/tun_wintun.rs b/examples/tun_wintun.rs index 5604986..1af173c 100644 --- a/examples/tun_wintun.rs +++ b/examples/tun_wintun.rs @@ -33,10 +33,10 @@ async fn main() -> Result<(), Box> { #[cfg(not(target_os = "windows"))] config.destination(_gateway); - #[cfg(target_os = "linux")] - config.platform_config(|config| { - config.packet_information(true); - }); + // #[cfg(target_os = "linux")] + // config.platform_config(|config| { + // config.ensure_root_privileges(true); + // }); let mut ipstack_config = ipstack::IpStackConfig::default(); ipstack_config.mtu(MTU);