Bump version 0.2.14

This commit is contained in:
ssrlive 2024-03-28 17:03:36 +08:00
parent eab795e61c
commit 4adc38c726
4 changed files with 12 additions and 4 deletions

View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -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));