Skip to content

Commit

Permalink
fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
mhils committed Dec 30, 2024
1 parent 0cdd415 commit dc0b512
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion mitmproxy-linux-ebpf-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ edition.workspace = true
rust-version.workspace = true
publish.workspace = true

[target.'cfg(not(windows))'.dependencies]
# aya-ebpf currently does not compile on Windows.
[target.'cfg(target_os = "linux")'.dependencies]
aya-ebpf = { workspace = true }

[lib]
Expand Down
6 changes: 3 additions & 3 deletions mitmproxy-linux-ebpf-common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![no_std]

// Weird compilation errors on Windows
#[cfg(not(windows))]
// aya-ebpf currently does not compile on Windows.
#[cfg(target_os = "linux")]
use aya_ebpf::TASK_COMM_LEN;
#[cfg(windows)]
#[cfg(not(target_os = "linux"))]
const TASK_COMM_LEN: usize = 16;

type Pid = u32;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
os.path.join(sysconfig.get_path("scripts"), "mitmproxy-linux-redirector"),
"."
)
]
]
5 changes: 2 additions & 3 deletions src/packet_sources/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ pub struct LinuxConf {
pub executable_path: PathBuf,
}

// We implement AsyncRead/AsyncWrite for UnixDatagram to have a common interface
// with Windows' NamedPipeServer.
pub struct AsyncUnixDatagram(UnixDatagram);

impl AsyncRead for AsyncUnixDatagram {
Expand Down Expand Up @@ -149,9 +151,6 @@ impl PacketSourceConf for LinuxConf {
let channel = UnixDatagram::bind(datagram_dir.path().join("mitmproxy"))?;
let dst = start_redirector(&self.executable_path, datagram_dir.path()).await?;

let _ = datagram_dir.into_path();
let datagram_dir = tempdir()?; // FIXME

channel
.connect(&dst)
.with_context(|| format!("Failed to connect to redirector at {}", dst.display()))?;
Expand Down
2 changes: 1 addition & 1 deletion src/packet_sources/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub trait PacketSourceTask: Send {
pub const IPC_BUF_SIZE: usize = MAX_PACKET_SIZE + 1024;

/// Feed packets from a socket into smol, and the other way around.
#[allow(dead_code)]
#[cfg(any(windows, target_os = "linux"))]
async fn forward_packets<T: AsyncRead + AsyncWrite + Unpin>(
mut channel: T,
transport_events_tx: Sender<TransportEvent>,
Expand Down

0 comments on commit dc0b512

Please sign in to comment.