Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mhils committed Oct 28, 2024
1 parent 1cfba5d commit 03a5c9a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions src/packet_sources/tun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
Expand All @@ -28,7 +28,7 @@ impl PacketSourceConf for TunConf {
transport_commands_rx: UnboundedReceiver<TransportCommand>,
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");
Expand All @@ -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) {
Expand Down Expand Up @@ -68,7 +68,7 @@ impl PacketSourceConf for TunConf {
}

pub struct TunTask {
device: tun2::AsyncDevice,
device: tun::AsyncDevice,

net_tx: Sender<NetworkEvent>,
net_rx: Receiver<NetworkCommand>,
Expand All @@ -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();
Expand Down

0 comments on commit 03a5c9a

Please sign in to comment.