pub mod aggregate;
#[cfg(target_os = "linux")]
pub mod linux;
#[cfg(target_os = "macos")]
pub mod macos;
pub use aggregate::{
DnsResolverKind, InterfaceKind, KillswitchKind, MockDns, MockInterface, MockKillswitch,
MockNetworkStats, MockRouteTable, NetworkStatsKind, Platform, RouteTableKind,
};
use std::sync::OnceLock;
static GLOBAL_PLATFORM: OnceLock<Platform> = OnceLock::new();
pub fn set_global_platform(platform: Platform) {
let _ = GLOBAL_PLATFORM.set(platform);
}
#[must_use]
pub fn current_platform() -> &'static Platform {
GLOBAL_PLATFORM.get_or_init(Platform::for_test)
}
#[cfg(not(any(target_os = "macos", target_os = "linux")))]
compile_error!("Vortix currently only supports macOS and Linux");
pub use crate::constants::DEFAULT_VPN_INTERFACE;
pub use crate::constants::KILLSWITCH_EMERGENCY_MSG;
pub use crate::vortix_core::ports::dns::DnsResolver;
pub use crate::vortix_core::ports::interface::Interface as InterfaceDetector;
pub use crate::vortix_core::ports::killswitch::Killswitch as Firewall;
pub use crate::vortix_core::ports::network_stats::NetworkStats as NetworkStatsProvider;
pub use crate::vortix_core::ports::route_table::RouteTable;
#[cfg(target_os = "macos")]
#[must_use]
pub fn install_hint(pkg: &str) -> String {
format!("brew install {pkg}")
}
#[cfg(target_os = "linux")]
#[must_use]
pub fn install_hint(pkg: &str) -> String {
match pkg {
"resolvconf (systemd)" => "\
sudo apt install systemd-resolved # Debian/Ubuntu (provides resolvconf shim)\n\
sudo pacman -S systemd-resolvconf # Arch\n\
sudo dnf install systemd-resolved # Fedora"
.to_string(),
"resolvconf" => "\
sudo apt install openresolv # Debian/Ubuntu\n\
sudo pacman -S openresolv # Arch\n\
sudo dnf install openresolv # Fedora"
.to_string(),
"wg" | "wg-quick" => "\
sudo apt install wireguard-tools # Debian/Ubuntu\n\
sudo pacman -S wireguard-tools # Arch\n\
sudo dnf install wireguard-tools # Fedora"
.to_string(),
_ => format!("sudo apt install {pkg} # or: sudo dnf install {pkg}"),
}
}