diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 08508de..a71cf33 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -1,6 +1,5 @@ pub mod hdlc; pub mod diag; -pub mod diag_device; pub mod qmdl; pub mod log_codes; pub mod gsmtap; @@ -9,5 +8,9 @@ pub mod pcap; pub mod analysis; pub mod util; +// bin/check.rs may target windows and does not use this mod +#[cfg(target_family = "unix")] +pub mod diag_device; + // re-export telcom_parser, since we use its types in our API pub use telcom_parser; diff --git a/lib/src/util.rs b/lib/src/util.rs index 5d719ea..457a440 100644 --- a/lib/src/util.rs +++ b/lib/src/util.rs @@ -1,6 +1,8 @@ -use nix::sys::utsname::uname; use serde::Serialize; +#[cfg(target_family = "unix")] +use nix::sys::utsname::uname; + /// Expose binary and system information. #[derive(Serialize, Debug)] pub struct RuntimeMetadata { @@ -23,6 +25,16 @@ impl RuntimeMetadata { /// attributes from `uname(2)` and falling back to values from /// `std::env::consts`. pub fn new() -> Self { + let build_target = RuntimeMetadata { + rayhunter_version: env!("CARGO_PKG_VERSION").to_owned(), + arch: std::env::consts::ARCH.to_string(), + system_os: std::env::consts::OS.to_string(), + }; + + #[cfg(target_family = "windows")] + return build_target; + + #[cfg(target_family = "unix")] match uname() { Ok(utsname) => RuntimeMetadata { rayhunter_version: env!("CARGO_PKG_VERSION").to_owned(), @@ -33,11 +45,7 @@ impl RuntimeMetadata { utsname.release().to_string_lossy(), ), }, - Err(_) => RuntimeMetadata { - rayhunter_version: env!("CARGO_PKG_VERSION").to_owned(), - arch: std::env::consts::ARCH.to_string(), - system_os: std::env::consts::OS.to_string(), - }, + Err(_) => build_target, } } }