diff --git a/crates/nu-command/src/system/sys/net.rs b/crates/nu-command/src/system/sys/net.rs index ee82f73c61..8e2ac19bf5 100644 --- a/crates/nu-command/src/system/sys/net.rs +++ b/crates/nu-command/src/system/sys/net.rs @@ -44,8 +44,29 @@ fn net(span: Span) -> Value { let networks = Networks::new_with_refreshed_list() .iter() .map(|(iface, data)| { + let ip_addresses = data + .ip_networks() + .iter() + .map(|ip| { + let protocol = match ip.addr { + std::net::IpAddr::V4(_) => "ipv4", + std::net::IpAddr::V6(_) => "ipv6", + }; + Value::record( + record! { + "address" => Value::string(ip.addr.to_string(), span), + "protocol" => Value::string(protocol, span), + "loop" => Value::bool(ip.addr.is_loopback(), span), + "multicast" => Value::bool(ip.addr.is_multicast(), span), + }, + span, + ) + }) + .collect(); let record = record! { "name" => Value::string(trim_cstyle_null(iface), span), + "mac" => Value::string(data.mac_address().to_string(), span), + "ip" => Value::list(ip_addresses, span), "sent" => Value::filesize(data.total_transmitted() as i64, span), "recv" => Value::filesize(data.total_received() as i64, span), };