X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=modules%2Fluci-base%2Fluasrc%2Ftools%2Fstatus.lua;h=06a9ad41546ef5d7fc6b849af5ce7684cb9e560a;hp=95ff46df15eeda415a808a1f6e5087caf23bd0ae;hb=HEAD;hpb=fecf6e1d11d466efa7b1bbf05633931a3081517e diff --git a/modules/luci-base/luasrc/tools/status.lua b/modules/luci-base/luasrc/tools/status.lua index 95ff46df1..06a9ad415 100644 --- a/modules/luci-base/luasrc/tools/status.lua +++ b/modules/luci-base/luasrc/tools/status.lua @@ -4,6 +4,7 @@ module("luci.tools.status", package.seeall) local uci = require "luci.model.uci".cursor() +local ipc = require "luci.ip" local function dhcp_leases_common(family) local rv = { } @@ -31,7 +32,7 @@ local function dhcp_leases_common(family) if family == 4 and not ip:match(":") then rv[#rv+1] = { expires = (expire ~= 0) and os.difftime(expire, os.time()), - macaddr = mac, + macaddr = ipc.checkmac(mac) or "00:00:00:00:00:00", ipaddr = ip, hostname = (name ~= "*") and name } @@ -74,19 +75,9 @@ local function dhcp_leases_common(family) hostname = (name ~= "-") and name } elseif ip and iaid == "ipv4" and family == 4 then - local mac, mac1, mac2, mac3, mac4, mac5, mac6 - if duid and type(duid) == "string" then - mac1, mac2, mac3, mac4, mac5, mac6 = duid:match("^(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)$") - end - if not (mac1 and mac2 and mac3 and mac4 and mac5 and mac6) then - mac = "FF:FF:FF:FF:FF:FF" - else - mac = mac1..":"..mac2..":"..mac3..":"..mac4..":"..mac5..":"..mac6 - end rv[#rv+1] = { expires = (expire >= 0) and os.difftime(expire, os.time()), - macaddr = duid, - macaddr = mac:lower(), + macaddr = ipc.checkmac(duid:gsub("^(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)$", "%1:%2:%3:%4:%5:%6")) or "00:00:00:00:00:00", ipaddr = ip, hostname = (name ~= "-") and name } @@ -196,7 +187,9 @@ function switch_status(devs) local switches = { } for dev in devs:gmatch("[^%s,]+") do local ports = { } - local swc = io.popen("swconfig dev %q show" % dev, "r") + local swc = io.popen("swconfig dev %s show" + % luci.util.shellquote(dev), "r") + if swc then local l repeat