mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-06-06 14:50:14 +00:00
switch to tun crate instead of tun2
This commit is contained in:
parent
b9cf06da33
commit
3fb02f0fc7
4 changed files with 8 additions and 9 deletions
|
@ -6,7 +6,7 @@ use crate::{
|
|||
};
|
||||
use std::os::raw::{c_char, c_int};
|
||||
use tproxy_config::{TproxyArgs, TUN_GATEWAY, TUN_IPV4, TUN_NETMASK};
|
||||
use tun2::{AbstractDevice, DEFAULT_MTU as MTU};
|
||||
use tun::{AbstractDevice, DEFAULT_MTU as MTU};
|
||||
|
||||
static TUN_QUIT: std::sync::Mutex<Option<tokio_util::sync::CancellationToken>> = std::sync::Mutex::new(None);
|
||||
|
||||
|
@ -83,7 +83,7 @@ pub unsafe extern "C" fn tun2proxy_with_name_run(
|
|||
pub async fn desktop_run_async(args: Args, shutdown_token: tokio_util::sync::CancellationToken) -> std::io::Result<()> {
|
||||
let bypass_ips = args.bypass.clone();
|
||||
|
||||
let mut tun_config = tun2::Configuration::default();
|
||||
let mut tun_config = tun::Configuration::default();
|
||||
tun_config.address(TUN_IPV4).netmask(TUN_NETMASK).mtu(MTU).up();
|
||||
tun_config.destination(TUN_GATEWAY);
|
||||
#[cfg(unix)]
|
||||
|
@ -122,7 +122,7 @@ pub async fn desktop_run_async(args: Args, shutdown_token: tokio_util::sync::Can
|
|||
#[allow(unused_mut, unused_assignments, unused_variables)]
|
||||
let mut setup = true;
|
||||
|
||||
let device = tun2::create_as_async(&tun_config)?;
|
||||
let device = tun::create_as_async(&tun_config)?;
|
||||
|
||||
if let Ok(tun_name) = device.tun_name() {
|
||||
tproxy_args = tproxy_args.tun_name(&tun_name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue