Skip to content

Commit

Permalink
small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
emanuele-em committed Aug 2, 2023
1 parent 6182c0c commit 1183d20
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
9 changes: 0 additions & 9 deletions src/intercept_conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,6 @@ impl InterceptConf {
};
format!("{}{}", start, parts.join(" or "))
}

// pub fn serialize(&self) -> Vec<u8> {
// let mut buf = Vec::new();
// let ipc = ipc::InterceptConf{pids: Vec::new(), process_names: self.process_names.clone(), invert: self.invert};
// buf.reserve(ipc.encoded_len());
// // Unwrap is safe, since we have reserved sufficient capacity in the vector.
// ipc.encode(&mut buf).unwrap();
// buf
// }
}

#[cfg(test)]
Expand Down
11 changes: 4 additions & 7 deletions src/packet_sources/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,18 @@ impl PipeServer {

fn create_pipe(path: &PathBuf) -> Result<(pipe::Receiver, pipe::Sender)> {
if !path.exists() {
match mkfifo(path, Mode::S_IRWXU) {
Ok(_) => println!("created {:?}", path),
Err(e) => Err(anyhow!("Failed to create fifo: {:?}", e))?,
}
mkfifo(path, Mode::S_IRWXU)?;
}
let rx = match pipe::OpenOptions::new()
.unchecked(true)
.open_receiver(&path)
.open_receiver(path)
{
Ok(rx) => rx,
Err(e) => Err(anyhow!("Failed to open fifo receiver: {:?}", e))?,
};
let tx = match pipe::OpenOptions::new().unchecked(true).open_sender(&path) {
let tx = match pipe::OpenOptions::new().unchecked(true).open_sender(path) {
Ok(tx) => tx,
Err(e) => Err(anyhow!("Failed to open fifo receiver: {:?}", e))?,
Err(e) => Err(anyhow!("Failed to open fifo transmitter: {:?}", e))?,
};

Ok((rx, tx))
Expand Down

0 comments on commit 1183d20

Please sign in to comment.