mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-10-26 19:02:52 +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
@@ -6,11 +6,10 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI support for fastnet
|
||||
LUCI_DEPENDS:=+fastnet
|
||||
LUCI_DEPENDS:=+fastnet +luci-lib-linkeaseauth
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=0.7.7-r1
|
||||
# PKG_RELEASE MUST be empty for luci.mk
|
||||
PKG_RELEASE:=
|
||||
PKG_VERSION:=0.7.7
|
||||
PKG_RELEASE:=3
|
||||
LUCI_MINIFY_CSS:=0
|
||||
LUCI_MINIFY_JS:=0
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -1,27 +1,12 @@
|
||||
local sys = require "luci.sys"
|
||||
local uci = require "luci.model.uci".cursor()
|
||||
local http = require "luci.http"
|
||||
local dispatcher = require "luci.dispatcher"
|
||||
|
||||
local m = Map("fastnet", translate("FastNet"))
|
||||
m.description = translate("FastNet provides network testing tools and a Web UI.")
|
||||
|
||||
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 st = m:section(SimpleSection, translate("Status"))
|
||||
local running = (sys.call("pidof FastNet >/dev/null") == 0)
|
||||
local listen_port = uci:get_first("fastnet", "fastnet", "port") or "3200"
|
||||
local token = uci:get_first("fastnet", "fastnet", "token") or ""
|
||||
local url = "http://" .. get_host() .. ":" .. listen_port .. "/"
|
||||
if token ~= "" then
|
||||
url = url .. "?token=" .. token
|
||||
end
|
||||
local url = dispatcher.build_url("admin", "services", "linkease_apps", "open") .. "?id=fastnet"
|
||||
|
||||
st.template = "fastnet/status"
|
||||
st.running = running
|
||||
|
||||
Reference in new issue
Block a user