applications/luci-splash: fix upper/lowercase issues in luci splash-cli, thanks to egon_ffj and patrick for spotting this

This commit is contained in:
Jo-Philipp Wich 2009-07-23 22:48:29 +00:00
parent 3c35ce382d
commit 7aacb0561d

View file

@ -45,7 +45,7 @@ function main(argv)
else else
for _, e in ipairs(arp_cache) do for _, e in ipairs(arp_cache) do
if e["IP address"] == adr then if e["IP address"] == adr then
mac = e["HW address"] mac = e["HW address"]:lower()
break break
end end
end end
@ -169,7 +169,7 @@ function get_known_ips(macs, arp)
local leased_ips = { } local leased_ips = { }
if not macs then macs = get_known_macs() end if not macs then macs = get_known_macs() end
for _, e in ipairs(arp or net.arptable()) do for _, e in ipairs(arp or net.arptable()) do
if macs[e["HW address"]] then leased_ips[e["IP address"]] = true end if macs[e["HW address"]:lower()] then leased_ips[e["IP address"]] = true end
end end
return leased_ips return leased_ips
end end
@ -199,7 +199,7 @@ function add_lease(mac, arp, no_uci)
-- Get current ip address -- Get current ip address
local ipaddr local ipaddr
for _, entry in ipairs(arp or net.arptable()) do for _, entry in ipairs(arp or net.arptable()) do
if entry["HW address"] == mac then if entry["HW address"]:lower() == mac then
ipaddr = entry["IP address"] ipaddr = entry["IP address"]
break break
end end
@ -380,7 +380,7 @@ function list()
-- Get current arp cache -- Get current arp cache
local arpcache = { } local arpcache = { }
for _, entry in ipairs(net.arptable()) do for _, entry in ipairs(net.arptable()) do
arpcache[entry["HW address"]] = { entry["Device"], entry["IP address"] } arpcache[entry["HW address"]:lower()] = { entry["Device"], entry["IP address"] }
end end
-- Find traffic usage -- Find traffic usage
@ -410,7 +410,7 @@ function list()
if s[".type"] == "lease" and s.mac then if s[".type"] == "lease" and s.mac then
local ti, to = traffic(s) local ti, to = traffic(s)
local mac = s.mac:lower() local mac = s.mac:lower()
local arp = arpcache[mac] local arp = arpcache[mac]:lower()
print(string.format( print(string.format(
"%-17s %-15s %-9s %3dm %-7s %7dKB %7dKB", "%-17s %-15s %-9s %3dm %-7s %7dKB %7dKB",
mac, s.ipaddr, "leased", mac, s.ipaddr, "leased",
@ -426,7 +426,7 @@ function list()
) do ) do
if (s[".type"] == "whitelist" or s[".type"] == "blacklist") and s.mac then if (s[".type"] == "whitelist" or s[".type"] == "blacklist") and s.mac then
local mac = s.mac:lower() local mac = s.mac:lower()
local arp = arpcache[mac] local arp = arpcache[mac]:lower()
print(string.format( print(string.format(
"%-17s %-15s %-9s %4s %-7s %9s %9s", "%-17s %-15s %-9s %4s %-7s %9s %9s",
mac, arp and arp[2] or "?", s[".type"], "- ", mac, arp and arp[2] or "?", s[".type"], "- ",