From 4f509cac2f8181a481690616a86fb4651c2a1ebe Mon Sep 17 00:00:00 2001 From: SajjadPourali Date: Thu, 21 Dec 2023 14:46:21 -0500 Subject: [PATCH] Update examples --- examples/tun.rs | 9 ++------- examples/wintun.rs | 8 +++----- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/examples/tun.rs b/examples/tun.rs index ccf2ff2..59c9969 100644 --- a/examples/tun.rs +++ b/examples/tun.rs @@ -23,14 +23,9 @@ async fn main() { config.packet_information(true); }); - #[cfg(not(target_os = "windows"))] let mut ipstack_config = ipstack::IpStackConfig::default(); - - #[cfg(target_os = "windows")] - let ipstack_config = ipstack::IpStackConfig::default(); - - #[cfg(not(target_os = "windows"))] - ipstack_config.packet_info(true); + ipstack_config.mtu(MTU); + ipstack_config.packet_info(cfg!(target_family = "unix")); let mut ip_stack = ipstack::IpStack::new(ipstack_config, tun::create_as_async(&config).unwrap()); diff --git a/examples/wintun.rs b/examples/wintun.rs index 8d0a140..ae0bc54 100644 --- a/examples/wintun.rs +++ b/examples/wintun.rs @@ -24,11 +24,9 @@ async fn main() { config.packet_information(true); }); - #[cfg(not(target_os = "windows"))] let mut ipstack_config = ipstack::IpStackConfig::default(); - - #[cfg(not(target_os = "windows"))] - ipstack_config.packet_info(true); + ipstack_config.mtu(MTU); + ipstack_config.packet_info(cfg!(target_family = "unix")); #[cfg(not(target_os = "windows"))] let mut ip_stack = @@ -36,7 +34,7 @@ async fn main() { #[cfg(target_os = "windows")] let mut ip_stack = ipstack::IpStack::new( - ipstack::IpStackConfig::default(), + ipstack_config, wintun::WinTunDevice::new(ipv4, Ipv4Addr::new(255, 255, 255, 0)), );