Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion src/interface/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,39 @@ pub fn interfaces() -> Vec<Interface> {

#[cfg(all(target_vendor = "apple", not(target_os = "macos")))]
pub fn interfaces() -> Vec<Interface> {
unix_interfaces()
let mut interfaces: Vec<Interface> = unix_interfaces();

#[cfg(feature = "gateway")]
let local_ip_opt: Option<IpAddr> = 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"))]
Expand Down
Loading