diff --git a/Cargo.lock b/Cargo.lock index d05e2331..823ce6d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1803,7 +1803,7 @@ dependencies = [ "sysinfo", "tokio", "tokio-util", - "tun2", + "tun", "windows 0.57.0", "x25519-dalek", ] @@ -2948,10 +2948,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] -name = "tun2" -version = "3.1.8" +name = "tun" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "294ac0e21fef392b8952f1dd538bc5752fd7c2ebfde1c204b0dd09aaa5489cd0" +checksum = "224cb7686e768be38d03dc660f88947b8976c1d68b8ee731324fe4b761ab80a2" dependencies = [ "bytes", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index f2bb3ad2..3a44e7f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,7 +47,7 @@ prost = "0.13.3" tokio-util = { version = "0.7.12", features = ["codec"] } futures-util = { version = "0.3.30", features = ["sink"] } lru_time_cache = "0.11.11" -internet-packet = { version = "0.2.0", features = ["smoltcp", "internet-checksum"] } +internet-packet = { version = "0.2.0", features = ["smoltcp"] } data-encoding = "2.4.0" hickory-resolver = "0.24.1" socket2 = "0.5.7" @@ -56,7 +56,6 @@ socket2 = "0.5.7" # tokio = { path = "../tokio/tokio" } smoltcp = { git = 'https://github.com/smoltcp-rs/smoltcp', rev = 'ef67e7b46cabf49783053cbf68d8671ed97ff8d4' } boringtun = { git = 'https://github.com/cloudflare/boringtun', rev = 'e3252d9c4f4c8fc628995330f45369effd4660a1' } -# tun2 = { path = "../rust-tun" } [target.'cfg(windows)'.dependencies.windows] version = "0.57.0" @@ -84,7 +83,7 @@ objc = "0.2" sysinfo = "0.29.10" [target.'cfg(target_os = "linux")'.dependencies] -tun2 = { version = "3.1.8", features = ["async"] } +tun = { version = "0.7.1", features = ["async"] } [dev-dependencies] env_logger = "0.11" diff --git a/src/packet_sources/tun.rs b/src/packet_sources/tun.rs index 22156c96..ba890ad0 100644 --- a/src/packet_sources/tun.rs +++ b/src/packet_sources/tun.rs @@ -8,7 +8,7 @@ use std::cmp::max; use std::fs; use tokio::sync::mpsc::{Permit, Receiver, UnboundedReceiver}; use tokio::sync::{broadcast, mpsc::Sender}; -use tun2::AbstractDevice; +use tun::AbstractDevice; pub struct TunConf { pub tun_name: Option, @@ -28,7 +28,7 @@ impl PacketSourceConf for TunConf { transport_commands_rx: UnboundedReceiver, shutdown: broadcast::Receiver<()>, ) -> Result<(Self::Task, Self::Data)> { - let mut config = tun2::Configuration::default(); + let mut config = tun::Configuration::default(); config.mtu(MAX_PACKET_SIZE as u16); // Setting a local address and a destination is required on Linux. config.address("169.254.0.1"); @@ -39,7 +39,7 @@ impl PacketSourceConf for TunConf { config.tun_name(&tun_name); } - let device = tun2::create_as_async(&config).context("Failed to create TUN device")?; + let device = tun::create_as_async(&config).context("Failed to create TUN device")?; let tun_name = device.tun_name().context("Failed to get TUN name")?; if let Err(e) = disable_rp_filter(&tun_name) { @@ -68,7 +68,7 @@ impl PacketSourceConf for TunConf { } pub struct TunTask { - device: tun2::AsyncDevice, + device: tun::AsyncDevice, net_tx: Sender, net_rx: Receiver, @@ -77,7 +77,7 @@ pub struct TunTask { impl PacketSourceTask for TunTask { async fn run(mut self) -> Result<()> { - let size = self.device.mtu()? as usize + tun2::PACKET_INFORMATION_LENGTH; + let size = self.device.mtu()? as usize + tun::PACKET_INFORMATION_LENGTH; let mut buf = vec![0; size]; let mut packet_to_send = Vec::new();