Skip to content

Commit

Permalink
Merge pull request #16 from ssrlive/main
Browse files Browse the repository at this point in the history
TUN_PROTO_IP6 issues
  • Loading branch information
SajjadPourali authored Jan 19, 2024
2 parents 0c8177a + 82c24a6 commit 0d76b50
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ async fn main(){

let mut ipstack_config = ipstack::IpStackConfig::default();
ipstack_config.mtu(MTU);
ipstack_config.packet_information(cfg!(unix));
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, tun::create_as_async(&config).unwrap());

while let Ok(stream) = ip_stack.accept().await {
Expand Down
3 changes: 2 additions & 1 deletion examples/tun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

let mut ipstack_config = ipstack::IpStackConfig::default();
ipstack_config.mtu(MTU);
ipstack_config.packet_information(cfg!(unix));
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
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ const TTL: u8 = 128;
#[cfg(unix)]
const TUN_FLAGS: [u8; 2] = [0x00, 0x00];

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
const TUN_PROTO_IP6: [u8; 2] = [0x86, 0xdd];
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
const TUN_PROTO_IP4: [u8; 2] = [0x08, 0x00];

#[cfg(target_os = "macos")]
const TUN_PROTO_IP6: [u8; 2] = [0x00, 0x02];
#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "ios"))]
const TUN_PROTO_IP6: [u8; 2] = [0x00, 0x0A];
#[cfg(any(target_os = "macos", target_os = "ios"))]
const TUN_PROTO_IP4: [u8; 2] = [0x00, 0x02];

pub struct IpStackConfig {
Expand Down

0 comments on commit 0d76b50

Please sign in to comment.