Skip to content

Commit

Permalink
update tun2 version and do not need to process packet info anymore on…
Browse files Browse the repository at this point in the history
… all platforms
  • Loading branch information
xmh0511 committed Jan 29, 2024
1 parent dd932b6 commit 602006f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ tokio = { version = "1.35", features = [
], default-features = false }

#tun2.rs example
tun2 = { version = "0.7", features = ["async"] }
tun2 = { version = "1.0.0", features = ["async"] }

#tun_wintun.rs example
[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dev-dependencies]
Expand Down
7 changes: 2 additions & 5 deletions examples/tun2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let gateway = Ipv4Addr::new(10, 0, 0, 1);

let mut config = tun2::Configuration::default();
config.address(ipv4).netmask(netmask).mtu(MTU as i32).up();
config.address(ipv4).netmask(netmask).mtu(MTU as usize).up();
config.destination(gateway);

#[cfg(target_os = "linux")]
config.platform_config(|config| {
config.packet_information(true);
config.apply_settings(true);
config.ensure_root_privileges(true);
});

#[cfg(target_os = "windows")]
Expand All @@ -68,8 +67,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

let mut ipstack_config = ipstack::IpStackConfig::default();
ipstack_config.mtu(MTU);
let packet_information = cfg!(all(target_family = "unix", not(target_os = "android")));
ipstack_config.packet_information(packet_information);

let mut ip_stack = ipstack::IpStack::new(ipstack_config, tun2::create_as_async(&config)?);

Expand Down

0 comments on commit 602006f

Please sign in to comment.