From 4adc38c7269523f629727270494bea717da3c94d Mon Sep 17 00:00:00 2001 From: ssrlive <30760636+ssrlive@users.noreply.github.com> Date: Thu, 28 Mar 2024 17:03:36 +0800 Subject: [PATCH] Bump version 0.2.14 --- Cargo.toml | 2 +- src/android.rs | 2 +- src/apple.rs | 4 +++- src/mobile_api.rs | 8 +++++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 518a553..1a00cf9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tun2proxy" -version = "0.2.13" +version = "0.2.14" edition = "2021" license = "MIT" repository = "https://github.com/blechschmidt/tun2proxy" diff --git a/src/android.rs b/src/android.rs index f89bb00..0f62d1c 100644 --- a/src/android.rs +++ b/src/android.rs @@ -39,7 +39,7 @@ pub unsafe extern "C" fn Java_com_github_shadowsocks_bg_Tun2proxy_run( let mut args = Args::default(); args.proxy(proxy).tun_fd(Some(tun_fd)).dns(dns).verbosity(verbosity); - crate::mobile_api::mobile_run(args, tun_mtu) + crate::mobile_api::mobile_run(args, tun_mtu, false) } /// # Safety diff --git a/src/apple.rs b/src/apple.rs index eba0676..66e0d66 100644 --- a/src/apple.rs +++ b/src/apple.rs @@ -12,6 +12,7 @@ use std::os::raw::{c_char, c_int, c_ushort}; /// Parameters: /// - proxy_url: the proxy url, e.g. "socks5://127.0.0.1:1080" /// - tun_fd: the tun file descriptor +/// - packet_information: whether exists packet information in tun_fd /// - tun_mtu: the tun mtu /// - dns_strategy: the dns strategy, see ArgDns enum /// - verbosity: the verbosity level, see ArgVerbosity enum @@ -19,6 +20,7 @@ use std::os::raw::{c_char, c_int, c_ushort}; pub unsafe extern "C" fn tun2proxy_with_fd_run( proxy_url: *const c_char, tun_fd: c_int, + packet_information: bool, tun_mtu: c_ushort, dns_strategy: ArgDns, verbosity: ArgVerbosity, @@ -32,7 +34,7 @@ pub unsafe extern "C" fn tun2proxy_with_fd_run( let mut args = Args::default(); args.proxy(proxy).tun_fd(Some(tun_fd)).dns(dns_strategy).verbosity(verbosity); - crate::mobile_api::mobile_run(args, tun_mtu) + crate::mobile_api::mobile_run(args, tun_mtu, packet_information) } /// # Safety diff --git a/src/mobile_api.rs b/src/mobile_api.rs index 8e67cef..645a06e 100644 --- a/src/mobile_api.rs +++ b/src/mobile_api.rs @@ -12,7 +12,7 @@ pub async fn desktop_run_async(_: Args, _: tokio_util::sync::CancellationToken) Ok(()) } -pub fn mobile_run(args: Args, tun_mtu: u16) -> c_int { +pub fn mobile_run(args: Args, tun_mtu: u16, _packet_information: bool) -> c_int { let shutdown_token = tokio_util::sync::CancellationToken::new(); { if let Ok(mut lock) = TUN_QUIT.lock() { @@ -41,6 +41,12 @@ pub fn mobile_run(args: Args, tun_mtu: u16) -> c_int { config.tun_name(tun); } + #[cfg(unix)] + config.platform_config(|config| { + #[allow(deprecated)] + config.packet_information(_packet_information); + }); + let device = tun2::create_as_async(&config).map_err(std::io::Error::from)?; let join_handle = tokio::spawn(crate::run(device, tun_mtu, args, shutdown_token));