luci-app-frps: add open page link (#8331)

Co-authored-by: zxlhhyccc <45259624+zxlhhyccc@users.noreply.github.com>
This commit is contained in:
Beginner 2021-11-28 00:41:07 +08:00 committed by GitHub
parent 5efd70f89f
commit 80bb1fbd20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 70 additions and 26 deletions

View File

@ -24,7 +24,7 @@ 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("root"))
local user local user
for user in luci.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)
@ -34,23 +34,29 @@ o = s:taboption("general", Flag, "enable_logging", translate("Enable logging"))
o = s:taboption("general", Value, "log_file", translate("Log file")) o = s:taboption("general", Value, "log_file", translate("Log file"))
o:depends("enable_logging", "1") o:depends("enable_logging", "1")
o.placeholder = "/var/log/frps.log" o.default = "/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", "Trace") o:value("trace",translate("Trace"))
o:value("debug", "Debug") o:value("debug",translate("Debug"))
o:value("info", "Info") o:value("info",translate("Info"))
o:value("warn", "Warn") o:value("warn",translate("Warning"))
o:value("error", "Error") o:value("error",translate("Error"))
o.default = "warn" o.default = "Warn"
o = s:taboption("general", Value, "log_max_days", translate("Log max days")) o = s:taboption("general", ListValue, "log_max_days", translate("Log max days"))
o.description = translate("Maximum number of days to keep log files is 3 day.")
o:depends("enable_logging", "1") o:depends("enable_logging", "1")
o.datatype = "uinteger" o.datatype = "uinteger"
o.placeholder = '3' o:value("1", translate("1"))
o:value("2", translate("2"))
o:value("3", translate("3"))
o.default = "3"
o.rmempty = false
o.optional = false
o = s:taboption("general", Value, "disable_log_color", translate("Disable log color")) o = s:taboption("general", Flag, "disable_log_color", translate("Disable log color"))
o:depends("enable_logging", "1") o:depends("enable_logging", "1")
o.enabled = "true" o.enabled = "true"
o.disabled = "false" o.disabled = "false"
@ -71,10 +77,12 @@ o.datatype = "host"
o = s:taboption("dashboard", Value, "dashboard_addr", translate("Dashboard 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.description = translatef("dashboard addr's default value is same with bind_addr")
o.default = "0.0.0.0"
o.datatype = "host" o.datatype = "host"
o = s:taboption("dashboard", Value, "dashboard_port", translate("Dashboard port")) o = s:taboption("dashboard", Value, "dashboard_port", translate("Dashboard port"))
o.description = translatef("dashboard is available only if dashboard_port is set") o.description = translatef("dashboard is available only if dashboard_port is set")
o.default = "7500"
o.datatype = "port" o.datatype = "port"
o = s:taboption("dashboard", Value, "dashboard_user", translate("Dashboard user")) o = s:taboption("dashboard", Value, "dashboard_user", translate("Dashboard user"))

View File

@ -4,13 +4,18 @@ XHR.poll(3, '<%=url([[admin]], [[services]], [[frps]], [[status]])%>', null,
var tb = document.getElementById('frps_status'); var tb = document.getElementById('frps_status');
if (data && tb) { if (data && tb) {
if (data.running) { if (data.running) {
tb.innerHTML = '<em><b><font color=green> <%:Frps%>' + data.bin_version + '<%:RUNNING%></font></b></em>'; tb.innerHTML = '<em><b><font color=green> <%:Frps%>' + data.bin_version + '<%:RUNNING%></font></b></em><input class="btn cbi-button mar-10" type="button" value="<%:Open Frps page%>" onclick="openwebui();" />';
} else { } else {
tb.innerHTML = '<em><b><font color=red> <%:Frps%>' + data.bin_version + '<%:NOT RUNNING%></font></b></em>'; tb.innerHTML = '<em><b><font color=red> <%:Frps%>' + data.bin_version + '<%:NOT RUNNING%></font></b></em>';
} }
} }
} }
); );
function openwebui(){
var url = window.location.host+":<%=luci.sys.exec("uci -q get frps.main.dashboard_port"):gsub("^%s*(.-)%s*$", "%1")%>";
window.open('http://'+url,'target','');
}
//]]> //]]>
</script> </script>
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style> <style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>

View File

@ -2,8 +2,8 @@ msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8" msgstr "Content-Type: text/plain; charset=UTF-8"
#: luasrc/model/cbi/frps/common.lua:54 #: luasrc/model/cbi/frps/common.lua:54
msgid "-- default --" # msgid "-- default --"
msgstr "-- 默认 --" # msgstr "-- 默认 --"
#: luasrc/model/cbi/frps/common.lua:44 #: luasrc/model/cbi/frps/common.lua:44
msgid "Advanced Options" msgid "Advanced Options"
@ -13,37 +13,37 @@ msgstr "高级选项"
msgid "Bind port" msgid "Bind port"
msgstr "绑定端口" msgstr "绑定端口"
#: luasrc/model/cbi/frps/common.lua:49 #: luasrc/model/cbi/frps/common.lua:22
msgid "Client file" msgid "Client file"
msgstr "客户端文件" msgstr "客户端文件"
#: luasrc/model/cbi/frps/common.lua:30 #: luasrc/model/cbi/frps/common.lua:7
msgid "Frps - Common Settings" msgid "Frps - Common Settings"
msgstr "Frps - 通用设置" msgstr "Frps - 通用设置"
#: luasrc/model/cbi/frps/common.lua:45 #: luasrc/model/cbi/frps/common.lua:18
msgid "Dashboard Options" msgid "Dashboard Options"
msgstr "面板选项" msgstr "面板选项"
#: luasrc/model/cbi/frps/common.lua:99 #: luasrc/model/cbi/frps/common.lua:78
msgid "Dashboard addr" msgid "Dashboard addr"
msgstr "面板绑定地址" msgstr "面板绑定地址"
#: luasrc/model/cbi/frps/common.lua:107 #: luasrc/model/cbi/frps/common.lua:91
msgid "Dashboard password" msgid "Dashboard password"
msgstr "面板登录密码" msgstr "面板登录密码"
#: luasrc/model/cbi/frps/common.lua:102 #: luasrc/model/cbi/frps/common.lua:83
msgid "Dashboard port" msgid "Dashboard port"
msgstr "面板绑定端口" msgstr "面板绑定端口"
#: luasrc/model/cbi/frps/common.lua:105 #: luasrc/model/cbi/frps/common.lua:88
msgid "Dashboard user" msgid "Dashboard user"
msgstr "面板登录用户名" msgstr "面板登录用户名"
#: luasrc/model/cbi/frps/common.lua:69 #: luasrc/model/cbi/frps/common.lua:69
msgid "Debug" # msgid "Debug"
msgstr "调试" # msgstr "调试"
#: luasrc/model/cbi/frps/common.lua:80 #: luasrc/model/cbi/frps/common.lua:80
msgid "Disable log color" msgid "Disable log color"
@ -93,10 +93,14 @@ msgstr "日志文件"
msgid "Log level" msgid "Log level"
msgstr "日志等级" msgstr "日志等级"
#: luasrc/model/cbi/frps/common.lua:75 #: luasrc/model/cbi/frps/common.lua:48
msgid "Log max days" msgid "Log max days"
msgstr "日志保存天数" msgstr "日志保存天数"
#: luasrc/model/cbi/frps/common.lua:49
msgid "Maximum number of days to keep log files is 3 day."
msgstr "保留日志文件的最大天数为 3 天。"
#: luasrc/model/cbi/frps/common.lua:85 #: luasrc/model/cbi/frps/common.lua:85
msgid "Max pool count" msgid "Max pool count"
msgstr "最大连接数" msgstr "最大连接数"
@ -170,9 +174,29 @@ msgid "UDP bind port"
msgstr "UDP绑定端口" msgstr "UDP绑定端口"
#: luasrc/model/cbi/frps/common.lua:71 #: luasrc/model/cbi/frps/common.lua:71
msgid "Warn" msgid "Log level"
msgstr "日志等级"
#: luasrc/model/cbi/frps/common.lua:41
msgid "Trace"
msgstr "追踪"
#: luasrc/model/cbi/frps/common.lua:42
msgid "Debug"
msgstr "调试"
#: luasrc/model/cbi/frps/common.lua:43
msgid "Info"
msgstr "信息"
#: luasrc/model/cbi/frps/common.lua:44
msgid "Warning"
msgstr "警告" msgstr "警告"
#: luasrc/model/cbi/frps/common.lua:45
msgid "Error"
msgstr "错误"
#: luasrc/model/cbi/frps/common.lua:99 #: luasrc/model/cbi/frps/common.lua:99
msgid "dashboard addr's default value is same with bind_addr" msgid "dashboard addr's default value is same with bind_addr"
msgstr "面板地址默认和绑定地址一致" msgstr "面板地址默认和绑定地址一致"
@ -220,3 +244,8 @@ 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>.(不含空格!)"
#: luasrc/view/frps/frps_status.htm:7
msgid "Open Frps page"
msgstr "打开 Frps 管理面板"

View File

@ -1,6 +1,8 @@
config frps 'main' config frps 'main'
option enabled '0' option enabled '0'
option server 'frps' option server 'frps'
option dashboard_addr '0.0.0.0'
option client_file '/usr/bin/frps' option client_file '/usr/bin/frps'
option bind_port '7000' option bind_port '7000'
option tcp_mux 'true' option dashboard_port '7500'
option tcp_mux 'true'