Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ 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",
"std_rng",
] }

[dev-dependencies]
tokio = { version = "1.39", features = [
tokio = { version = "1.41", features = [
"rt-multi-thread",
], default-features = false }
clap = { version = "4.5", features = ["derive"] }
Expand All @@ -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 }

Expand Down
6 changes: 3 additions & 3 deletions examples/tun2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//! ```
Expand Down Expand Up @@ -81,7 +81,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
#[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
Expand All @@ -101,7 +101,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
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;

Expand Down
14 changes: 7 additions & 7 deletions examples/tun_wintun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -33,14 +33,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
#[cfg(not(target_os = "windows"))]
config.destination(_gateway);

#[cfg(target_os = "linux")]
config.platform(|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 as u16);
ipstack_config.packet_information(cfg!(target_family = "unix"));
ipstack_config.mtu(MTU);
// 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)?);
Expand Down