mwol: change to LF

This commit is contained in:
AmadeusGhost 2020-03-11 10:01:04 +08:00
parent dd74723386
commit afd56edf1e
2 changed files with 67 additions and 67 deletions

View File

@ -1,11 +1,11 @@
--Copyright (C) 2019 mleaf <mleaf90@gmail.com>
--微信公众号【WiFi物联网】
module("luci.controller.mwol",package.seeall)
function index()
if not nixio.fs.access("/etc/config/mwol") then
return
end
local page = entry({"admin", "services", "mwol"}, cbi("mwol"), _("Mwol"))
page.dependent = true
end
--Copyright (C) 2019 mleaf <mleaf90@gmail.com>
--微信公众号【WiFi物联网】
module("luci.controller.mwol",package.seeall)
function index()
if not nixio.fs.access("/etc/config/mwol") then
return
end
local page = entry({"admin", "services", "mwol"}, cbi("mwol"), _("Mwol"))
page.dependent = true
end

View File

@ -1,56 +1,56 @@
#!/usr/bin/env lua
--Copyright (c) 2019 www.mleaf.org. All rights reserved.
--微信公众号【WiFi物联网】
ubus = require('ubus')
local json = require "luci.json"
local conn = ubus.connect()
if not conn then
error("Failed to connect to ubus")
end
local mwol_ubus = conn:call("uci", "get", {config = "mwol"})
local mwol_table = mwol_ubus["values"]
local mwol_conf = {}
local mwo_enable
function get_mwol_conf(mTable)
for key, val in pairs(mTable) do
if string.match(key, '%.[%a]*', 1) == nil then
if key == "enable" then
mwo_enable = val
elseif key == "sslenable" then
if val == "1" then
mwol_conf["ssl"] = true
else
mwol_conf["ssl"] = false
end
elseif key=="encryptionenable" then
if val == "1" then
mwol_conf["encryption"] = true
else
mwol_conf["encryption"] = false
end
elseif key == "port" then
mwol_conf[key] = tonumber(val)
else
mwol_conf[key] = val
end
end
end
end
for key, val in pairs(mwol_table) do
if key == "mwol_conf" then
get_mwol_conf(val)
end
end
jsonStr = json.encode(mwol_conf)
print(jsonStr)
#!/usr/bin/env lua
--Copyright (c) 2019 www.mleaf.org. All rights reserved.
--微信公众号【WiFi物联网】
ubus = require('ubus')
local json = require "luci.json"
local conn = ubus.connect()
if not conn then
error("Failed to connect to ubus")
end
local mwol_ubus = conn:call("uci", "get", {config = "mwol"})
local mwol_table = mwol_ubus["values"]
local mwol_conf = {}
local mwo_enable
function get_mwol_conf(mTable)
for key, val in pairs(mTable) do
if string.match(key, '%.[%a]*', 1) == nil then
if key == "enable" then
mwo_enable = val
elseif key == "sslenable" then
if val == "1" then
mwol_conf["ssl"] = true
else
mwol_conf["ssl"] = false
end
elseif key=="encryptionenable" then
if val == "1" then
mwol_conf["encryption"] = true
else
mwol_conf["encryption"] = false
end
elseif key == "port" then
mwol_conf[key] = tonumber(val)
else
mwol_conf[key] = val
end
end
end
end
for key, val in pairs(mwol_table) do
if key == "mwol_conf" then
get_mwol_conf(val)
end
end
jsonStr = json.encode(mwol_conf)
print(jsonStr)