mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-16 04:13:31 +00:00
luci-app-frps: fix status bar (#8315)
This commit is contained in:
parent
f07303d327
commit
c2ed5616ef
@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
|
|||||||
|
|
||||||
PKG_NAME:=luci-app-frps
|
PKG_NAME:=luci-app-frps
|
||||||
PKG_VERSION:=0.0.2
|
PKG_VERSION:=0.0.2
|
||||||
PKG_RELEASE:=3
|
PKG_RELEASE:=4
|
||||||
|
|
||||||
PKG_LICENSE:=MIT
|
PKG_LICENSE:=MIT
|
||||||
PKG_LICENSE_FILES:=LICENSE
|
PKG_LICENSE_FILES:=LICENSE
|
||||||
@ -24,16 +24,4 @@ endef
|
|||||||
|
|
||||||
include $(TOPDIR)/feeds/luci/luci.mk
|
include $(TOPDIR)/feeds/luci/luci.mk
|
||||||
|
|
||||||
define Package/$(PKG_NAME)/postinst
|
|
||||||
#!/bin/sh
|
|
||||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
|
||||||
( . /etc/uci-defaults/40_luci-frps ) && rm -f /etc/uci-defaults/40_luci-frps
|
|
||||||
fi
|
|
||||||
|
|
||||||
chmod 755 "$${IPKG_INSTROOT}/etc/init.d/frps" >/dev/null 2>&1
|
|
||||||
ln -sf "../init.d/frps" \
|
|
||||||
"$${IPKG_INSTROOT}/etc/rc.d/S99frps" >/dev/null 2>&1
|
|
||||||
exit 0
|
|
||||||
endef
|
|
||||||
|
|
||||||
# call BuildPackage - OpenWrt buildroot signature
|
# call BuildPackage - OpenWrt buildroot signature
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
-- Copyright 2020 lwz322 <lwz322@qq.com>
|
-- Copyright 2020 lwz322 <lwz322@qq.com>
|
||||||
-- Licensed to the public under the MIT License.
|
-- Licensed to the public under the MIT License.
|
||||||
|
|
||||||
local http = require "luci.http"
|
|
||||||
local uci = require "luci.model.uci".cursor()
|
|
||||||
local sys = require "luci.sys"
|
|
||||||
|
|
||||||
module("luci.controller.frps", package.seeall)
|
module("luci.controller.frps", package.seeall)
|
||||||
|
|
||||||
function index()
|
function index()
|
||||||
@ -22,18 +18,9 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function action_status()
|
function action_status()
|
||||||
local running = false
|
local e = {}
|
||||||
|
e.running = luci.sys.call("pidof frps >/dev/null") == 0
|
||||||
local client = uci:get("frps", "main", "client_file")
|
e.bin_version = luci.sys.exec("frps -v")
|
||||||
if client and client ~= "" then
|
luci.http.prepare_content("application/json")
|
||||||
local file_name = client:match(".*/([^/]+)$") or ""
|
luci.http.write_json(e)
|
||||||
if file_name ~= "" then
|
|
||||||
running = sys.call("pidof %s >/dev/null" % file_name) == 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
http.prepare_content("application/json")
|
|
||||||
http.write_json({
|
|
||||||
running = running
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
@ -1,40 +1,13 @@
|
|||||||
-- Copyright 2020 lwz322 <lwz322@qq.com>
|
-- Copyright 2020 lwz322 <lwz322@qq.com>
|
||||||
-- Licensed to the public under the MIT License.
|
-- Licensed to the public under the MIT License.
|
||||||
|
|
||||||
local uci = require "luci.model.uci".cursor()
|
|
||||||
local util = require "luci.util"
|
|
||||||
local fs = require "nixio.fs"
|
|
||||||
local sys = require "luci.sys"
|
|
||||||
|
|
||||||
local m, s, o
|
local m, s, o
|
||||||
local server_table = { }
|
|
||||||
|
|
||||||
local function frps_version()
|
m = Map("frps")
|
||||||
local file = uci:get("frps", "main", "client_file")
|
m.title = translate("Frps - Common Settings")
|
||||||
|
m.description = translate("Frp is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.<br/><a href=\"https://github.com/fatedier/frp\" target=\"_blank\">Project GitHub URL</a>")
|
||||||
|
|
||||||
if not file or file == "" or not fs.stat(file) then
|
m:section(SimpleSection).template = "frps/frps_status"
|
||||||
return "<em style=\"color: red;\">%s</em>" % translate("Invalid client file")
|
|
||||||
end
|
|
||||||
|
|
||||||
if not fs.access(file, "rwx", "rx", "rx") then
|
|
||||||
fs.chmod(file, 755)
|
|
||||||
end
|
|
||||||
|
|
||||||
local version = util.trim(sys.exec("%s -v 2>/dev/null" % file))
|
|
||||||
if version == "" then
|
|
||||||
return "<em style=\"color: red;\">%s</em>" % translate("Can't get client version")
|
|
||||||
end
|
|
||||||
return translatef("Version: %s", version)
|
|
||||||
end
|
|
||||||
|
|
||||||
m = Map("frps", "%s - %s" % { translate("Frps"), translate("Common Settings") },
|
|
||||||
"<p>%s</p><p>%s</p>" % {
|
|
||||||
translate("Frp is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet."),
|
|
||||||
translatef("For more information, please visit: %s",
|
|
||||||
"<a href=\"https://github.com/fatedier/frp\" target=\"_blank\">https://github.com/fatedier/frp</a>")
|
|
||||||
})
|
|
||||||
|
|
||||||
m:append(Template("frps/status_header"))
|
|
||||||
|
|
||||||
s = m:section(NamedSection, "main", "frps")
|
s = m:section(NamedSection, "main", "frps")
|
||||||
s.addremove = false
|
s.addremove = false
|
||||||
@ -46,14 +19,14 @@ s:tab("dashboard", translate("Dashboard Options"))
|
|||||||
|
|
||||||
o = s:taboption("general", Flag, "enabled", translate("Enabled"))
|
o = s:taboption("general", Flag, "enabled", translate("Enabled"))
|
||||||
|
|
||||||
o = s:taboption("general", Value, "client_file", translate("Client file"), frps_version())
|
o = s:taboption("general", Value, "client_file", translate("Client file"))
|
||||||
o.datatype = "file"
|
o.default = "/usr/bin/frps"
|
||||||
o.rmempty = false
|
o.rmempty = false
|
||||||
|
|
||||||
o = s:taboption("general", ListValue, "run_user", translate("Run daemon as user"))
|
o = s:taboption("general", ListValue, "run_user", translate("Run daemon as user"))
|
||||||
o:value("", translate("-- default --"))
|
o:value("", translate("-- default --"))
|
||||||
local user
|
local user
|
||||||
for user in util.execi("cat /etc/passwd | cut -d':' -f1") do
|
for user in luci.util.execi("cat /etc/passwd | cut -d':' -f1") do
|
||||||
o:value(user)
|
o:value(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -65,11 +38,11 @@ o.placeholder = "/var/log/frps.log"
|
|||||||
|
|
||||||
o = s:taboption("general", ListValue, "log_level", translate("Log level"))
|
o = s:taboption("general", ListValue, "log_level", translate("Log level"))
|
||||||
o:depends("enable_logging", "1")
|
o:depends("enable_logging", "1")
|
||||||
o:value("trace", translate("Trace"))
|
o:value("trace", "Trace")
|
||||||
o:value("debug", translate("Debug"))
|
o:value("debug", "Debug")
|
||||||
o:value("info", translate("Info"))
|
o:value("info", "Info")
|
||||||
o:value("warn", translate("Warn"))
|
o:value("warn", "Warn")
|
||||||
o:value("error", translate("Error"))
|
o:value("error", "Error")
|
||||||
o.default = "warn"
|
o.default = "warn"
|
||||||
|
|
||||||
o = s:taboption("general", Value, "log_max_days", translate("Log max days"))
|
o = s:taboption("general", Value, "log_max_days", translate("Log max days"))
|
||||||
@ -82,27 +55,30 @@ o:depends("enable_logging", "1")
|
|||||||
o.enabled = "true"
|
o.enabled = "true"
|
||||||
o.disabled = "false"
|
o.disabled = "false"
|
||||||
|
|
||||||
o = s:taboption("advanced", Value, "max_pool_count", translate("Max pool count"),
|
o = s:taboption("advanced", Value, "max_pool_count", translate("Max pool count"))
|
||||||
translate("pool_count in each proxy will change to max_pool_count if they exceed the maximum value"))
|
o.description = translate("pool_count in each proxy will change to max_pool_count if they exceed the maximum value")
|
||||||
o.datatype = "uinteger"
|
o.datatype = "uinteger"
|
||||||
|
|
||||||
o = s:taboption("advanced", Value, "max_ports_per_client", translate("Max ports per-client"),
|
o = s:taboption("advanced", Value, "max_ports_per_client", translate("Max ports per-client"))
|
||||||
translate("max ports can be used for each client, default value is 0 means no limit"))
|
o.description = translate("max ports can be used for each client, default value is 0 means no limit")
|
||||||
o.datatype = "uinteger"
|
o.datatype = "uinteger"
|
||||||
o.defalut = '0'
|
o.defalut = '0'
|
||||||
o.placeholder = '0'
|
o.placeholder = '0'
|
||||||
|
|
||||||
o = s:taboption("advanced", Value, "subdomain_host", translate("Subdomain host"),
|
o = s:taboption("advanced", Value, "subdomain_host", translate("Subdomain host"))
|
||||||
translatef("if subdomain_host is not empty, you can set subdomain when type is http or https in frpc's configure file; when subdomain is test, the host used by routing is test.frps.com"))
|
o.description = translatef("if subdomain_host is not empty, you can set subdomain when type is http or https in frpc's configure file; when subdomain is test, the host used by routing is test.frps.com")
|
||||||
o.datatype = "host"
|
o.datatype = "host"
|
||||||
|
|
||||||
o = s:taboption("dashboard", Value, "dashboard_addr", translate("Dashboard addr"), translatef("dashboard addr's default value is same with bind_addr"))
|
o = s:taboption("dashboard", Value, "dashboard_addr", translate("Dashboard addr"))
|
||||||
|
o.description = translatef("dashboard addr's default value is same with bind_addr")
|
||||||
o.datatype = "host"
|
o.datatype = "host"
|
||||||
|
|
||||||
o = s:taboption("dashboard", Value, "dashboard_port", translate("Dashboard port"), translatef("dashboard is available only if dashboard_port is set"))
|
o = s:taboption("dashboard", Value, "dashboard_port", translate("Dashboard port"))
|
||||||
|
o.description = translatef("dashboard is available only if dashboard_port is set")
|
||||||
o.datatype = "port"
|
o.datatype = "port"
|
||||||
|
|
||||||
o = s:taboption("dashboard", Value, "dashboard_user", translate("Dashboard user"), translatef("dashboard user and passwd for basic auth protect, if not set, both default value is admin"))
|
o = s:taboption("dashboard", Value, "dashboard_user", translate("Dashboard user"))
|
||||||
|
o.description = translatef("dashboard user and passwd for basic auth protect, if not set, both default value is admin")
|
||||||
|
|
||||||
o = s:taboption("dashboard", Value, "dashboard_pwd", translate("Dashboard password"))
|
o = s:taboption("dashboard", Value, "dashboard_pwd", translate("Dashboard password"))
|
||||||
o.password = true
|
o.password = true
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
-- Copyright 2020 lwz322 <lwz322@qq.com>
|
-- Copyright 2020 lwz322 <lwz322@qq.com>
|
||||||
-- Licensed to the public under the MIT License.
|
-- Licensed to the public under the MIT License.
|
||||||
|
|
||||||
local dsp = require "luci.dispatcher"
|
|
||||||
|
|
||||||
local m, s, o
|
local m, s, o
|
||||||
|
|
||||||
m = Map("frps", "%s - %s" % { translate("Frps"), translate("FRPS Server setting") })
|
m = Map("frps")
|
||||||
|
m.title = translate("Frps - Server Settings")
|
||||||
|
m.description = translate("FRPS Server Settings")
|
||||||
|
|
||||||
s = m:section(NamedSection, "main", "frps")
|
s = m:section(NamedSection, "main", "frps")
|
||||||
s.anonymous = true
|
s.anonymous = true
|
||||||
|
21
package/lean/luci-app-frps/luasrc/view/frps/frps_status.htm
Normal file
21
package/lean/luci-app-frps/luasrc/view/frps/frps_status.htm
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<script type="text/javascript">//<![CDATA[
|
||||||
|
XHR.poll(3, '<%=url([[admin]], [[services]], [[frps]], [[status]])%>', null,
|
||||||
|
function(x, data) {
|
||||||
|
var tb = document.getElementById('frps_status');
|
||||||
|
if (data && tb) {
|
||||||
|
if (data.running) {
|
||||||
|
tb.innerHTML = '<em><b><font color=green> <%:Frps%>' + data.bin_version + '<%:RUNNING%></font></b></em>';
|
||||||
|
} else {
|
||||||
|
tb.innerHTML = '<em><b><font color=red> <%:Frps%>' + data.bin_version + '<%:NOT RUNNING%></font></b></em>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
//]]>
|
||||||
|
</script>
|
||||||
|
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||||
|
<fieldset class="cbi-section">
|
||||||
|
<p id="frps_status">
|
||||||
|
<em><%:Collecting data...%></em>
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
@ -1,29 +0,0 @@
|
|||||||
<%#
|
|
||||||
Copyright 2020 lwz322 <lwz322@qq.com>
|
|
||||||
Licensed to the public under the MIT License.
|
|
||||||
-%>
|
|
||||||
|
|
||||||
<%
|
|
||||||
local dsp = require "luci.dispatcher"
|
|
||||||
-%>
|
|
||||||
|
|
||||||
<fieldset class="cbi-section">
|
|
||||||
<p id="frps_status">
|
|
||||||
<em><%:Collecting data...%></em>
|
|
||||||
</p>
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
<script type="text/javascript">//<![CDATA[
|
|
||||||
XHR.poll(5, '<%=dsp.build_url("admin/services/frps/status")%>', null,
|
|
||||||
function (x, data) {
|
|
||||||
if (x.status !== 200 || !data) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var frpsStatusElm = document.getElementById('frps_status');
|
|
||||||
frpsStatusElm.innerHTML = data.running
|
|
||||||
? '<%:Running%>'
|
|
||||||
: '<%:Not Running%>';
|
|
||||||
}
|
|
||||||
);
|
|
||||||
//]]></script>
|
|
@ -13,21 +13,13 @@ msgstr "高级选项"
|
|||||||
msgid "Bind port"
|
msgid "Bind port"
|
||||||
msgstr "绑定端口"
|
msgstr "绑定端口"
|
||||||
|
|
||||||
#: luasrc/model/cbi/frps/common.lua:25
|
|
||||||
msgid "Can't get client version"
|
|
||||||
msgstr "无法获取到客户端版本"
|
|
||||||
|
|
||||||
#: luasrc/model/cbi/frps/common.lua:49
|
#: luasrc/model/cbi/frps/common.lua:49
|
||||||
msgid "Client file"
|
msgid "Client file"
|
||||||
msgstr "客户端文件"
|
msgstr "客户端文件"
|
||||||
|
|
||||||
#: luasrc/view/frps/status_header.htm:12
|
|
||||||
msgid "Collecting data..."
|
|
||||||
msgstr "正在收集数据..."
|
|
||||||
|
|
||||||
#: luasrc/model/cbi/frps/common.lua:30
|
#: luasrc/model/cbi/frps/common.lua:30
|
||||||
msgid "Common Settings"
|
msgid "Frps - Common Settings"
|
||||||
msgstr "通用设置"
|
msgstr "Frps - 通用设置"
|
||||||
|
|
||||||
#: luasrc/model/cbi/frps/common.lua:45
|
#: luasrc/model/cbi/frps/common.lua:45
|
||||||
msgid "Dashboard Options"
|
msgid "Dashboard Options"
|
||||||
@ -70,23 +62,16 @@ msgid "Error"
|
|||||||
msgstr "错误"
|
msgstr "错误"
|
||||||
|
|
||||||
#: luasrc/model/cbi/frps/server.lua:8
|
#: luasrc/model/cbi/frps/server.lua:8
|
||||||
msgid "FRPS Server setting"
|
msgid "Frps - Server Settings"
|
||||||
|
msgstr "Frps - 服务器设定"
|
||||||
|
|
||||||
|
#: luasrc/model/cbi/frps/server.lua:8
|
||||||
|
msgid "FRPS Server Settings"
|
||||||
msgstr "Frps 服务器设定"
|
msgstr "Frps 服务器设定"
|
||||||
|
|
||||||
#: luasrc/model/cbi/frps/common.lua:33
|
|
||||||
msgid "For more information, please visit: %s"
|
|
||||||
msgstr "获取更多信息,请访问:%s"
|
|
||||||
|
|
||||||
#: luasrc/model/cbi/frps/common.lua:32
|
#: luasrc/model/cbi/frps/common.lua:32
|
||||||
msgid ""
|
msgid "Frp is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.<br/><a href=\"https://github.com/fatedier/frp\" target=\"_blank\">Project GitHub URL</a>"
|
||||||
"Frp is a fast reverse proxy to help you expose a local server behind a NAT "
|
msgstr "Frp 是一个可用于内网穿透的高性能的反向代理应用。<br/><a href=\"https://github.com/fatedier/frp\" target=\"_blank\">Github 项目地址</a>"
|
||||||
"or firewall to the internet."
|
|
||||||
msgstr "Frp 是一个可用于内网穿透的高性能的反向代理应用。"
|
|
||||||
|
|
||||||
#: luasrc/controller/frps.lua:16 luasrc/model/cbi/frps/common.lua:30
|
|
||||||
#: luasrc/model/cbi/frps/server.lua:8
|
|
||||||
msgid "Frps"
|
|
||||||
msgstr "Frps"
|
|
||||||
|
|
||||||
#: luasrc/model/cbi/frps/common.lua:43
|
#: luasrc/model/cbi/frps/common.lua:43
|
||||||
msgid "General Options"
|
msgid "General Options"
|
||||||
@ -96,10 +81,6 @@ msgstr "常规选项"
|
|||||||
msgid "Info"
|
msgid "Info"
|
||||||
msgstr "信息"
|
msgstr "信息"
|
||||||
|
|
||||||
#: luasrc/model/cbi/frps/common.lua:16
|
|
||||||
msgid "Invalid client file"
|
|
||||||
msgstr "客户端文件无效"
|
|
||||||
|
|
||||||
#: luasrc/model/cbi/frps/server.lua:31
|
#: luasrc/model/cbi/frps/server.lua:31
|
||||||
msgid "KCP bind port"
|
msgid "KCP bind port"
|
||||||
msgstr "KCP绑定端口"
|
msgstr "KCP绑定端口"
|
||||||
@ -152,10 +133,6 @@ msgstr "(可选)UDP端口用于KCP协议,可与绑定端口设定为一致
|
|||||||
msgid "Run daemon as user"
|
msgid "Run daemon as user"
|
||||||
msgstr "以用户身份运行"
|
msgstr "以用户身份运行"
|
||||||
|
|
||||||
#: luasrc/view/frps/status_header.htm:25
|
|
||||||
msgid "Running"
|
|
||||||
msgstr "服务正在运行"
|
|
||||||
|
|
||||||
#: luasrc/controller/frps.lua:22
|
#: luasrc/controller/frps.lua:22
|
||||||
msgid "Server"
|
msgid "Server"
|
||||||
msgstr "服务端"
|
msgstr "服务端"
|
||||||
@ -192,10 +169,6 @@ msgstr "追踪"
|
|||||||
msgid "UDP bind port"
|
msgid "UDP bind port"
|
||||||
msgstr "UDP绑定端口"
|
msgstr "UDP绑定端口"
|
||||||
|
|
||||||
#: luasrc/model/cbi/frps/common.lua:27
|
|
||||||
msgid "Version: %s"
|
|
||||||
msgstr "版本:%s"
|
|
||||||
|
|
||||||
#: luasrc/model/cbi/frps/common.lua:71
|
#: luasrc/model/cbi/frps/common.lua:71
|
||||||
msgid "Warn"
|
msgid "Warn"
|
||||||
msgstr "警告"
|
msgstr "警告"
|
||||||
@ -246,4 +219,4 @@ msgstr "额外设置"
|
|||||||
|
|
||||||
#: luasrc/model/cbi/frps/server.lua:51
|
#: luasrc/model/cbi/frps/server.lua:51
|
||||||
msgid "List of extra settings will be added to config file. Format: option=value, eg. <code>detailed_errors_to_client=false</code>.(NO SPACE!)"
|
msgid "List of extra settings will be added to config file. Format: option=value, eg. <code>detailed_errors_to_client=false</code>.(NO SPACE!)"
|
||||||
msgstr "额外设置列表将会被添加到config文件中。 格式:option=value,如:<code>detailed_errors_to_client=false</code>.(不含空格!)"
|
msgstr "额外设置列表将会被添加到config文件中。 格式:option=value,如:<code>detailed_errors_to_client=false</code>.(不含空格!)"
|
||||||
|
Loading…
Reference in New Issue
Block a user