Skip to content

Commit

Permalink
Set pcap direction when supported (due to better performance)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Aug 19, 2024
1 parent cbaee06 commit 23c8dba
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions talpid-core/src/split_tunnel/macos/tun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -818,10 +818,12 @@ fn capture_outbound_packets(
.open()
.map_err(Error::CaptureSplitTunnelDevice)?;

// TODO: This is unsupported on macOS 13 and lower, so we determine the direction using the
// pktap header flags. Once macOS 13 is no longer supported, this can be uncommented.
// cap.direction(pcap::Direction::Out)
// .map_err(Error::SetDirection)?;
// TODO: `Capture::direction` is unsupported on macOS 13 and lower, so we determine the
// direction using the pktap header as well. Once macOS 13 is no longer supported,
// this can be assumed to work. Filtering here appears to be a lot faster.
if let Err(error) = cap.direction(pcap::Direction::Out) {
log::debug!("Failed to set capture direction. Might be on macOS 13: {error}");
}

let cap = cap.setnonblock().map_err(Error::EnableNonblock)?;
let stream = cap
Expand Down

0 comments on commit 23c8dba

Please sign in to comment.