luci-mod-admin-full: use :ipaddrs() and :ip6addrs() helper for iface_status
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 17 Nov 2015 16:36:00 +0000 (17:36 +0100)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 17 Nov 2015 16:36:00 +0000 (17:36 +0100)
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
modules/luci-mod-admin-full/luasrc/controller/admin/network.lua

index 879e54b2495376b8d227c6dbef9361f100360f34..aa533cb70b1262c6fdb6ba3b61e5b260e4adc167 100644 (file)
@@ -235,6 +235,8 @@ function iface_status(ifaces)
                                proto      = net:proto(),
                                uptime     = net:uptime(),
                                gwaddr     = net:gwaddr(),
+                               ipaddrs    = net:ipaddrs(),
+                               ip6addrs   = net:ip6addrs(),
                                dnsaddrs   = net:dnsaddrs(),
                                name       = device:shortname(),
                                type       = device:type(),
@@ -246,29 +248,9 @@ function iface_status(ifaces)
                                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
-                               if not a:is6linklocal() then
-                                       data.ip6addrs[#data.ip6addrs+1] = {
-                                               addr      = a:host():string(),
-                                               netmask   = a:mask():string(),
-                                               prefix    = a:prefix()
-                                       }
-                               end
-                       end
-
                        for _, device in ipairs(net:get_interfaces() or {}) do
                                data.subdevices[#data.subdevices+1] = {
                                        name       = device:shortname(),