Skip to content

Commit

Permalink
Update to tun 0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Feb 11, 2025
1 parent 950cca5 commit ea1260b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 50 deletions.
52 changes: 8 additions & 44 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion talpid-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ hickory-server = { workspace = true, features = ["resolver"] }
talpid-platform-metadata = { path = "../talpid-platform-metadata" }
pcap = { version = "2.1", features = ["capture-stream"] }
pnet_packet = { workspace = true }
tun = { version = "0.5.5", features = ["async"] }
tun = { workspace = true }
nix = { version = "0.28", features = ["socket", "signal"] }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
Expand Down
10 changes: 5 additions & 5 deletions talpid-core/src/split_tunnel/macos/tun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use tokio::{
io::{AsyncReadExt, AsyncWriteExt},
sync::broadcast,
};
use tun::Device;
use tun::AbstractDevice;

/// IP address used by the ST utun
const ST_IFACE_IPV4: Ipv4Addr = Ipv4Addr::new(10, 123, 123, 123);
Expand Down Expand Up @@ -194,7 +194,7 @@ async fn create_utun() -> Result<tun::AsyncDevice, Error> {
tun_config.address(ST_IFACE_IPV4).up();
let tun_device =
tun::create_as_async(&tun_config).map_err(Error::CreateSplitTunnelInterface)?;
let tun_name = tun_device.get_ref().name().to_owned();
let tun_name = tun_device.tun_name().unwrap().to_owned();
add_ipv6_address(&tun_name, ST_IFACE_IPV6).await?;
Ok(tun_device)
}
Expand Down Expand Up @@ -231,7 +231,7 @@ fn redirect_packets(
route_manager: RouteManagerHandle,
classify: ClassifyFn,
) -> Result<SplitTunnelHandle, Error> {
let pktap_stream = capture_outbound_packets(st_tun_device.get_ref().name())?;
let pktap_stream = capture_outbound_packets(&st_tun_device.tun_name().unwrap())?;
redirect_packets_for_pktap_stream(
st_tun_device,
Box::pin(pktap_stream),
Expand Down Expand Up @@ -260,15 +260,15 @@ fn redirect_packets_for_pktap_stream(
) -> Result<SplitTunnelHandle, Error> {
let mtu_listener = vpn_interface.as_ref().map(|vpn_interface| {
tokio::spawn(mtu_updater(
st_tun_device.get_ref().name().to_owned(),
st_tun_device.tun_name().unwrap().to_owned(),
vpn_interface.name.clone(),
route_manager.clone(),
))
});

let (default_stream, default_write, read_buffer_size) = open_default_bpf(&default_interface)?;

let st_utun_name = st_tun_device.get_ref().name().to_owned();
let st_utun_name = st_tun_device.tun_name().unwrap().to_owned();

let (abort_tx, abort_rx) = broadcast::channel(1);
let abort_read_rx = abort_tx.subscribe();
Expand Down

0 comments on commit ea1260b

Please sign in to comment.