Skip to content

Commit

Permalink
Add support for more operating systems.
Browse files Browse the repository at this point in the history
This commit will add support for other bsd like systems then
macos.

Signed-off-by: Valdemar Erk <valdemar@erk.io>
  • Loading branch information
Erk- committed Jan 11, 2020
1 parent 21938b6 commit 5e7ff99
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/network/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl Protocol {
// Currently, linux implementation doesn't use this function.
// Without this #[cfg] clippy complains about dead code, and CI refuses
// to pass.
#[cfg(target_os = "macos")]
#[cfg(all(target_family = "unix", not(target_os = "linux")))]
pub fn from_str(string: &str) -> Option<Self> {
match string {
"TCP" => Some(Protocol::Tcp),
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/os/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#[cfg(target_os = "linux")]
pub(self) mod linux;

#[cfg(target_os = "macos")]
pub(self) mod macos;
#[cfg(all(target_family = "unix", not(target_os = "linux")))]
pub(self) mod bsd;

#[cfg(target_os = "macos")]
#[cfg(all(target_family = "unix", not(target_os = "linux")))]
mod lsof_utils;

mod shared;
Expand Down
6 changes: 3 additions & 3 deletions src/os/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use signal_hook::iterator::Signals;

#[cfg(target_os = "linux")]
use crate::os::linux::get_open_sockets;
#[cfg(target_os = "macos")]
use crate::os::macos::get_open_sockets;
#[cfg(all(target_family = "unix", not(target_os = "linux")))]
use crate::os::bsd::get_open_sockets;
use crate::{network::dns, OsInputOutput};

pub type OnSigWinch = dyn Fn(Box<dyn Fn()>) + Send;
Expand Down Expand Up @@ -143,7 +143,7 @@ pub fn get_input(
}

#[inline]
#[cfg(target_os = "macos")]
#[cfg(all(target_family = "unix", not(target_os = "linux")))]
fn eperm_message() -> &'static str {
"Insufficient permissions to listen on network interface(s). Try running with sudo."
}
Expand Down

0 comments on commit 5e7ff99

Please sign in to comment.