Merge pull request #965 from cshore-firmware/pull-request-odhcpd-mac

base: status: For odhpcd leases display MAC formatted with colons
This commit is contained in:
Daniel Dickinson 2017-02-07 16:00:09 -05:00 committed by GitHub
commit fecf6e1d11

View file

@ -74,9 +74,19 @@ 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(),
ipaddr = ip,
hostname = (name ~= "-") and name
}