diff --git a/src/interface/unix.rs b/src/interface/unix.rs index 8e49c0e..36897df 100644 --- a/src/interface/unix.rs +++ b/src/interface/unix.rs @@ -97,7 +97,39 @@ pub fn interfaces() -> Vec { #[cfg(all(target_vendor = "apple", not(target_os = "macos")))] pub fn interfaces() -> Vec { - unix_interfaces() + let mut interfaces: Vec = unix_interfaces(); + + #[cfg(feature = "gateway")] + let local_ip_opt: Option = super::get_local_ipaddr(); + + #[cfg(feature = "gateway")] + let gateway_map = gateway::macos::get_gateway_map(); + + for iface in &mut interfaces { + #[cfg(feature = "gateway")] + { + if let Some(gateway) = gateway_map.get(&iface.index) { + iface.gateway = Some(gateway.clone()); + } + + if let Some(local_ip) = local_ip_opt { + iface.ipv4.iter().for_each(|ipv4| { + if IpAddr::V4(ipv4.addr()) == local_ip { + iface.dns_servers = get_system_dns_conf(); + iface.default = true; + } + }); + iface.ipv6.iter().for_each(|ipv6| { + if IpAddr::V6(ipv6.addr()) == local_ip { + iface.dns_servers = get_system_dns_conf(); + iface.default = true; + } + }); + } + } + } + + interfaces } #[cfg(any(target_os = "linux", target_os = "android"))]