mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-10-30 06:55:13 +08:00
update 2026-09-23 17:00:17
This commit is contained in:
1 parent
4c14ad0233
commit
77395e0373
99 files changed
+23008
-876
No files matched your search
@@ -1,44 +1,29 @@
|
||||
module("luci.controller.fastnet", package.seeall)
|
||||
|
||||
function index()
|
||||
local fs = require "nixio.fs"
|
||||
if not fs.access("/etc/config/fastnet") then
|
||||
return
|
||||
end
|
||||
if not nixio.fs.access("/etc/config/fastnet") then return end
|
||||
|
||||
entry({"admin", "services", "fastnet"}, cbi("fastnet"), _("FastNet"), 50).dependent = true
|
||||
entry({"admin", "services", "fastnet", "status"}, call("action_status")).leaf = true
|
||||
local open = entry({"admin", "services", "fastnet", "open"}, call("action_open"))
|
||||
open.leaf = true
|
||||
open.dependent = false
|
||||
open.sysauth = false
|
||||
end
|
||||
|
||||
local function compat()
|
||||
return require("luci.model.linkease.apps_compat").new()
|
||||
end
|
||||
|
||||
function action_status()
|
||||
local sys = require "luci.sys"
|
||||
local uci = require "luci.model.uci".cursor()
|
||||
local http = require "luci.http"
|
||||
|
||||
local function get_host()
|
||||
local host = http.getenv("HTTP_HOST") or http.getenv("SERVER_NAME") or ""
|
||||
host = host:gsub(":%d+$", "")
|
||||
if host == "_redirect2ssl" or host == "redirect2ssl" or host == "" then
|
||||
host = http.getenv("SERVER_ADDR") or "localhost"
|
||||
end
|
||||
return host
|
||||
end
|
||||
|
||||
local running = (sys.call("pidof FastNet >/dev/null") == 0)
|
||||
local host = get_host()
|
||||
local port = uci:get_first("fastnet", "fastnet", "port") or "3200"
|
||||
local token = uci:get_first("fastnet", "fastnet", "token") or ""
|
||||
|
||||
local url = "http://" .. host .. ":" .. port .. "/"
|
||||
if token ~= "" then
|
||||
url = url .. "?token=" .. token
|
||||
end
|
||||
|
||||
http.prepare_content("application/json")
|
||||
http.write_json({
|
||||
running = running,
|
||||
host = host,
|
||||
port = port,
|
||||
url = url
|
||||
compat():legacy_status("fastnet", {
|
||||
running = sys.call("pidof FastNet >/dev/null") == 0,
|
||||
port = uci:get_first("fastnet", "fastnet", "port") or "3200"
|
||||
})
|
||||
end
|
||||
|
||||
function action_open()
|
||||
compat():open("fastnet")
|
||||
end
|
||||
Reference in new issue
Block a user