summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-wol
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2018-03-12 16:12:18 +0100
committerJo-Philipp Wich <jo@mein.io>2018-03-12 16:12:18 +0100
commit28e3b328545529c19429ce88c7d1769e64e2de0f (patch)
tree3d7d85d7d4d1202199bad98df125f2af88b73c86 /applications/luci-app-wol
parentdfba318140e1a84359e221b7a9154337595dbded (diff)
treewide: unify mac address handling
Use the new luci.ip MAC address facilities to parse and verify MAC addresses in a common way, instead of relying on various ad-hoc solutions. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'applications/luci-app-wol')
-rw-r--r--applications/luci-app-wol/luasrc/model/cbi/wol.lua8
1 files changed, 5 insertions, 3 deletions
diff --git a/applications/luci-app-wol/luasrc/model/cbi/wol.lua b/applications/luci-app-wol/luasrc/model/cbi/wol.lua
index ec6a1be2a..d40dde017 100644
--- a/applications/luci-app-wol/luasrc/model/cbi/wol.lua
+++ b/applications/luci-app-wol/luasrc/model/cbi/wol.lua
@@ -2,6 +2,7 @@
-- Licensed to the public under the Apache License 2.0.
local sys = require "luci.sys"
+local ipc = require "luci.ip"
local fs = require "nixio.fs"
m = SimpleForm("wol", translate("Wake on LAN"),
@@ -58,7 +59,8 @@ end
function host.write(self, s, val)
local host = luci.http.formvalue("cbid.wol.1.mac")
- if host and #host > 0 and host:match("^[a-fA-F0-9:]+$") then
+ local mac = ipc.checkmac(host)
+ if mac then
local cmd
local util = luci.http.formvalue("cbid.wol.1.binary") or (
has_ewk and "/usr/bin/etherwake" or "/usr/bin/wol"
@@ -69,10 +71,10 @@ function host.write(self, s, val)
local broadcast = luci.http.formvalue("cbid.wol.1.broadcast")
cmd = "%s -D%s %s %q" %{
util, (iface ~= "" and " -i %q" % iface or ""),
- (broadcast == "1" and " -b" or ""), host
+ (broadcast == "1" and " -b" or ""), mac
}
else
- cmd = "%s -v %q" %{ util, host }
+ cmd = "%s -v %q" %{ util, mac }
end
local msg = "<p><strong>%s</strong><br /><br /><code>%s<br /><br />" %{