diff --git a/easytier/src/common/network.rs b/easytier/src/common/network.rs index 408fb104..f817efb4 100644 --- a/easytier/src/common/network.rs +++ b/easytier/src/common/network.rs @@ -1,4 +1,6 @@ -use std::{collections::HashMap, net::IpAddr}; +#[cfg(not(mobile))] +use std::collections::HashMap; +use std::net::IpAddr; use network_interface::{NetworkInterface, NetworkInterfaceConfig}; #[cfg(all(target_os = "macos", not(feature = "macos-ne")))] @@ -8,6 +10,7 @@ use crate::proto::peer_rpc::GetIpListResponse; use super::netns::NetNS; +#[cfg(not(mobile))] #[derive(Clone, Copy, Debug, Default)] struct InterfaceState { is_point_to_point: bool, @@ -46,6 +49,7 @@ fn collect_interface_states() -> HashMap { states } +#[cfg(not(mobile))] #[cfg(not(any( all(target_os = "linux", not(target_env = "ohos")), all(target_os = "macos", not(feature = "macos-ne")), @@ -99,11 +103,13 @@ pub(crate) fn ip_mask_to_prefix(mask: IpAddr) -> Result { } } +#[cfg(not(mobile))] struct InterfaceFilter { iface: NetworkInterface, state: InterfaceState, } +#[cfg(not(mobile))] fn interface_state( iface: &NetworkInterface, states: &HashMap, @@ -117,18 +123,6 @@ fn interface_state( }) } -#[cfg(any( - target_os = "android", - target_os = "ios", - all(target_os = "macos", feature = "macos-ne"), - target_env = "ohos" -))] -impl InterfaceFilter { - async fn filter_iface(&self) -> bool { - true - } -} - #[cfg(all(target_os = "linux", not(target_env = "ohos")))] impl InterfaceFilter { async fn is_tun_tap_device(&self) -> bool { @@ -363,22 +357,31 @@ async fn collect_interfaces_in_current_namespace(filter: bool) -> Vec Result { + // OHOS reports target_os = "linux", but has neither systemd nor OpenRC. + if cfg!(target_env = "ohos") { + return Err(std::io::Error::new( + std::io::ErrorKind::Unsupported, + "System service management is not supported on HarmonyOS; run easytier-core in the foreground", + ) + .into()); + } + #[cfg(target_os = "windows")] let service_manager = Box::new(self::win_service_manager::WinServiceManager::new()?); #[cfg(all(target_os = "macos", not(feature = "macos-ne")))]