2022-02-12 16:05:03 +08:00
|
|
|
module("luci.controller.v2raya", package.seeall)
|
|
|
|
|
|
|
|
function index()
|
|
|
|
if not nixio.fs.access("/etc/config/v2raya") then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2022-09-11 23:44:21 +08:00
|
|
|
local page = entry({"admin", "services", "v2raya"}, alias("admin", "services", "v2raya", "basic"), _("v2rayA"), 30)
|
2022-02-12 16:05:03 +08:00
|
|
|
page.dependent = true
|
|
|
|
page.acl_depends = { "luci-app-v2raya" }
|
|
|
|
|
2022-09-11 23:44:21 +08:00
|
|
|
entry({"admin", "services", "v2raya", "basic"}, cbi("v2raya/basic")).leaf = true
|
|
|
|
entry({"admin", "services", "v2raya", "log"}, cbi("v2raya/log")).leaf = true
|
2022-09-11 19:15:54 +08:00
|
|
|
entry({"admin", "services", "v2raya", "get_log"}, call("get_log")).leaf = true
|
|
|
|
entry({"admin", "services", "v2raya", "clear_log"}, call("clear_log")).leaf = true
|
2022-09-11 23:44:21 +08:00
|
|
|
entry({"admin", "services", "v2raya", "status"}, call("act_status")).leaf = true
|
2022-02-12 16:05:03 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function act_status()
|
|
|
|
local e = {}
|
|
|
|
e.running = luci.sys.call("pgrep -f v2raya >/dev/null") == 0
|
|
|
|
luci.http.prepare_content("application/json")
|
|
|
|
luci.http.write_json(e)
|
|
|
|
end
|
2022-09-11 19:15:54 +08:00
|
|
|
|
|
|
|
function get_log()
|
|
|
|
luci.http.write(luci.sys.exec("[ -f $(uci -q get v2raya.config.log_file) ] && cat $(uci -q get v2raya.config.log_file)"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function clear_log()
|
|
|
|
luci.sys.call("echo '' > $(uci -q get v2raya.config.log_file)")
|
|
|
|
end
|