- for iface in path[#path]:gmatch("[%w%.%-]+") do
- local dev
- if x:get("network", iface, "type") == "bridge" then
- dev = "br-" .. iface
- else
- dev = x:get("network", iface, "device") or ""
- end
-
- if #dev == 0 or dev:match("^%d") or dev:match("%W") then
- dev = x:get("network", iface, "ifname") or ""
- dev = dev:match("%S+")
- end
+ for iface in path[#path]:gmatch("[%w%.%-_]+") do
+ local net = netm:get_network(iface)
+ local device = net and net:get_interface()
+ if device then
+ local device = net:get_interface()
+ local data = {
+ id = iface,
+ proto = net:proto(),
+ uptime = net:uptime(),
+ gwaddr = net:gwaddr(),
+ dnsaddrs = net:dnsaddrs(),
+ name = device:shortname(),
+ type = device:type(),
+ ifname = device:name(),
+ macaddr = device:mac(),
+ is_up = device:is_up(),
+ rx_bytes = device:rx_bytes(),
+ tx_bytes = device:tx_bytes(),
+ rx_packets = device:rx_packets(),
+ tx_packets = device:tx_packets(),
+
+ ipaddrs = { },
+ ip6addrs = { },
+ subdevices = { }
+ }
+
+ local _, a
+ for _, a in ipairs(device:ipaddrs()) do
+ data.ipaddrs[#data.ipaddrs+1] = {
+ addr = a:host():string(),
+ netmask = a:mask():string(),
+ prefix = a:prefix()
+ }
+ end
+ for _, a in ipairs(device:ip6addrs()) do
+ data.ip6addrs[#data.ip6addrs+1] = {
+ addr = a:host():string(),
+ netmask = a:mask():string(),
+ prefix = a:prefix()
+ }
+ end