summaryrefslogtreecommitdiffhomepage
path: root/applications
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2010-11-24 04:19:23 +0000
committerJo-Philipp Wich <jow@openwrt.org>2010-11-24 04:19:23 +0000
commit168f025719868f6fc723fa87c27e71bad5027aa6 (patch)
tree2ad96167f75b0e1b817996d1270eda9693898f53 /applications
parentcbe2cb545ce847ddb488ecf52141f560f6cab9ed (diff)
applications/luci-wol: add static lease macs to suggestion list
Diffstat (limited to 'applications')
-rw-r--r--applications/luci-wol/luasrc/model/cbi/wol.lua17
1 files changed, 13 insertions, 4 deletions
diff --git a/applications/luci-wol/luasrc/model/cbi/wol.lua b/applications/luci-wol/luasrc/model/cbi/wol.lua
index bf192ee88..ac73919e2 100644
--- a/applications/luci-wol/luasrc/model/cbi/wol.lua
+++ b/applications/luci-wol/luasrc/model/cbi/wol.lua
@@ -10,6 +10,8 @@ You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
]]--
+local uci = require "luci.model.uci".cursor()
+local utl = require "luci.util"
local sys = require "luci.sys"
local fs = require "nixio.fs"
@@ -54,23 +56,30 @@ end
for _, e in ipairs(sys.net.arptable()) do
- arp[e["HW address"]] = { e["IP address"] }
+ arp[e["HW address"]:upper()] = { e["IP address"] }
end
for e in io.lines("/etc/ethers") do
mac, ip = e:match("^([a-f0-9]%S+) (%S+)")
- if mac and ip then arp[mac] = { ip } end
+ if mac and ip then arp[mac:upper()] = { ip } end
end
for e in io.lines("/var/dhcp.leases") do
mac, ip, name = e:match("^%d+ (%S+) (%S+) (%S+)")
- if mac and ip then arp[mac] = { ip, name ~= "*" and name } end
+ if mac and ip then arp[mac:upper()] = { ip, name ~= "*" and name } end
end
+uci:foreach("dhcp", "host",
+ function(s)
+ if s.mac and s.ip then
+ arp[s.mac:upper()] = { s.ip, s.name }
+ end
+ end)
+
host = s:option(Value, "mac", translate("Host to wake up"),
translate("Choose the host to wake up or enter a custom MAC address to use"))
-for mac, ip in pairs(arp) do
+for mac, ip in utl.kspairs(arp) do
host:value(mac, "%s (%s)" %{ mac, ip[2] or ip[1] })
end