mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-29 19:45:13 +08:00
🌴 Sync 2026-03-05 23:51:42
This commit is contained in:
1 parent
97c049ed0a
commit
0acff03804
14253 files changed
+3893239
No files matched your search
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# Copyright 2020 lwz322 <lwz322@qq.com>
|
||||
# Licensed to the public under the MIT License.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-frps
|
||||
PKG_VERSION:=0.0.2
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_LICENSE:=MIT
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
PKG_MAINTAINER:=lwz322 <lwz322@qq.com>
|
||||
|
||||
LUCI_TITLE:=LuCI support for Frps
|
||||
LUCI_DEPENDS:=+wget +frps
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
define Package/$(PKG_NAME)/conffiles
|
||||
/etc/config/frps
|
||||
endef
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
@@ -0,0 +1,24 @@
|
||||
-- Copyright 2020 lwz322 <lwz322@qq.com>
|
||||
-- Licensed to the public under the MIT License.
|
||||
|
||||
module("luci.controller.frps", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/frps") then
|
||||
return
|
||||
end
|
||||
|
||||
entry({"admin", "services", "frps"}, alias("admin", "services", "frps", "common"), _("Frps"), 99).dependent = true
|
||||
entry({"admin", "services", "frps", "common"}, cbi("frps/common"), _("Settings"), 1).leaf = true
|
||||
entry({"admin", "services", "frps", "server"}, cbi("frps/server"), _("Server"), 2).leaf = true
|
||||
entry({"admin", "services", "frps", "status"}, call("action_status")).leaf = true
|
||||
end
|
||||
|
||||
|
||||
function action_status()
|
||||
local e = {}
|
||||
e.running = luci.sys.call("pidof frps >/dev/null") == 0
|
||||
e.bin_version = luci.sys.exec("frps -v")
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
@@ -0,0 +1,93 @@
|
||||
-- Copyright 2020 lwz322 <lwz322@qq.com>
|
||||
-- Licensed to the public under the MIT License.
|
||||
|
||||
local m, s, o
|
||||
|
||||
m = Map("frps")
|
||||
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>")
|
||||
|
||||
m:section(SimpleSection).template = "frps/frps_status"
|
||||
|
||||
s = m:section(NamedSection, "main", "frps")
|
||||
s.addremove = false
|
||||
s.anonymous = true
|
||||
|
||||
s:tab("general", translate("General Options"))
|
||||
s:tab("advanced", translate("Advanced Options"))
|
||||
s:tab("dashboard", translate("Dashboard Options"))
|
||||
|
||||
o = s:taboption("general", Flag, "enabled", translate("Enabled"))
|
||||
|
||||
o = s:taboption("general", Value, "client_file", translate("Client file"))
|
||||
o.default = "/usr/bin/frps"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:taboption("general", ListValue, "run_user", translate("Run daemon as user"))
|
||||
o:value("", translate("root"))
|
||||
local user
|
||||
for user in luci.util.execi("cat /etc/passwd | cut -d':' -f1") do
|
||||
o:value(user)
|
||||
end
|
||||
|
||||
o = s:taboption("general", Flag, "enable_logging", translate("Enable logging"))
|
||||
|
||||
o = s:taboption("general", Value, "log_file", translate("Log file"))
|
||||
o:depends("enable_logging", "1")
|
||||
o.default = "/var/log/frps.log"
|
||||
|
||||
o = s:taboption("general", ListValue, "log_level", translate("Log level"))
|
||||
o:depends("enable_logging", "1")
|
||||
o:value("trace", translate("Trace"))
|
||||
o:value("debug", translate("Debug"))
|
||||
o:value("info", translate("Info"))
|
||||
o:value("warn", translate("Warning"))
|
||||
o:value("error", translate("Error"))
|
||||
o.default = "Warn"
|
||||
|
||||
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.datatype = "uinteger"
|
||||
o:value("1", translate("1"))
|
||||
o:value("2", translate("2"))
|
||||
o:value("3", translate("3"))
|
||||
o.default = "3"
|
||||
o.optional = false
|
||||
|
||||
o = s:taboption("general", Flag, "disable_log_color", translate("Disable log color"))
|
||||
o:depends("enable_logging", "1")
|
||||
o.enabled = "true"
|
||||
o.disabled = "false"
|
||||
|
||||
o = s:taboption("advanced", Value, "max_pool_count", translate("Max pool count"))
|
||||
o.description = translate("pool_count in each proxy will change to max_pool_count if they exceed the maximum value")
|
||||
o.datatype = "uinteger"
|
||||
|
||||
o = s:taboption("advanced", Value, "max_ports_per_client", translate("Max ports per-client"))
|
||||
o.description = translate("max ports can be used for each client, default value is 0 means no limit")
|
||||
o.datatype = "uinteger"
|
||||
o.defalut = '0'
|
||||
o.placeholder = '0'
|
||||
|
||||
o = s:taboption("advanced", Value, "subdomain_host", translate("Subdomain host"))
|
||||
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 = s:taboption("dashboard", Value, "dashboard_addr", translate("Dashboard addr"))
|
||||
o.description = translatef("dashboard addr's default value is same with bind_addr")
|
||||
o.default = "0.0.0.0"
|
||||
o.datatype = "host"
|
||||
|
||||
o = s:taboption("dashboard", Value, "dashboard_port", translate("Dashboard port"))
|
||||
o.description = translatef("dashboard is available only if dashboard_port is set")
|
||||
o.default = "7500"
|
||||
o.datatype = "port"
|
||||
|
||||
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.password = true
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,54 @@
|
||||
-- Copyright 2020 lwz322 <lwz322@qq.com>
|
||||
-- Licensed to the public under the MIT License.
|
||||
|
||||
local m, s, o
|
||||
|
||||
m = Map("frps")
|
||||
m.title = translate("Frps - Server Settings")
|
||||
m.description = translate("FRPS Server Settings")
|
||||
|
||||
s = m:section(NamedSection, "main", "frps")
|
||||
s.anonymous = true
|
||||
s.addremove = false
|
||||
|
||||
o = s:option(Value, "bind_port", translate("Bind port"))
|
||||
o.datatype = "port"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "token", translate("Token"))
|
||||
o.password = true
|
||||
|
||||
o = s:option(Flag, "tcp_mux", translate("TCP mux"))
|
||||
o.enabled = "true"
|
||||
o.disabled = "false"
|
||||
o.defalut = o.enabled
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Flag, "tls_only", translate("Enforce frps only accept TLS connection"))
|
||||
o.description = translatef("Requirements: frpc v0.25.0+, frps v0.32.0+")
|
||||
o.enabled = "true"
|
||||
o.disabled = "false"
|
||||
o.default = o.disabled
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "bind_udp_port", translate("UDP bind port"))
|
||||
o.description = translatef("Optional: udp port to help make udp hole to penetrate nat")
|
||||
o.datatype = "port"
|
||||
|
||||
o = s:option(Value, "kcp_bind_port", translate("KCP bind port"))
|
||||
o.description = translatef("Optional: udp port used for kcp protocol, it can be same with 'bind port'; if not set, kcp is disabled in frps")
|
||||
o.datatype = "port"
|
||||
|
||||
o = s:option(Value, "vhost_http_port", translate("vhost http port"))
|
||||
o.description = translatef("Optional: if you want to support virtual host, you must set the http port for listening")
|
||||
o.datatype = "port"
|
||||
|
||||
o = s:option(Value, "vhost_https_port", translate("vhost https port"))
|
||||
o.description = translatef("Optional: Note: http port and https port can be same with bind_port")
|
||||
o.datatype = "port"
|
||||
|
||||
o = s:option(DynamicList, "extra_setting", translate("Extra Settings"))
|
||||
o.description = translatef("List of extra settings will be added to config file. Format: option=value, eg. <code>detailed_errors_to_client=false</code>.(NO SPACE!)")
|
||||
o.placeholder = "option=value"
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,26 @@
|
||||
<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><input class="btn cbi-button mar-10" type="button" value="<%:Open Frps page%>" onclick="openwebui();" />';
|
||||
} else {
|
||||
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>
|
||||
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||
<fieldset class="cbi-section">
|
||||
<p id="frps_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
||||
@@ -0,0 +1,250 @@
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=UTF-8"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:54
|
||||
# msgid "-- default --"
|
||||
# msgstr "-- 默认 --"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:44
|
||||
msgid "Advanced Options"
|
||||
msgstr "高级选项"
|
||||
|
||||
#: luasrc/model/cbi/frps/server.lua:14
|
||||
msgid "Bind port"
|
||||
msgstr "绑定端口"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:22
|
||||
msgid "Client file"
|
||||
msgstr "客户端文件"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:7
|
||||
msgid "Frps - Common Settings"
|
||||
msgstr "Frps - 通用设置"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:18
|
||||
msgid "Dashboard Options"
|
||||
msgstr "面板选项"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:78
|
||||
msgid "Dashboard addr"
|
||||
msgstr "面板绑定地址"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:91
|
||||
msgid "Dashboard password"
|
||||
msgstr "面板登录密码"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:83
|
||||
msgid "Dashboard port"
|
||||
msgstr "面板绑定端口"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:88
|
||||
msgid "Dashboard user"
|
||||
msgstr "面板登录用户名"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:69
|
||||
# msgid "Debug"
|
||||
# msgstr "调试"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:80
|
||||
msgid "Disable log color"
|
||||
msgstr "禁用日志颜色"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:60
|
||||
msgid "Enable logging"
|
||||
msgstr "启用日志"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:47
|
||||
msgid "Enabled"
|
||||
msgstr "已启用"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:72
|
||||
msgid "Error"
|
||||
msgstr "错误"
|
||||
|
||||
#: luasrc/model/cbi/frps/server.lua:8
|
||||
msgid "Frps - Server Settings"
|
||||
msgstr "Frps - 服务器设定"
|
||||
|
||||
#: luasrc/model/cbi/frps/server.lua:8
|
||||
msgid "FRPS Server Settings"
|
||||
msgstr "Frps 服务器设定"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:32
|
||||
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>"
|
||||
msgstr "Frp 是一个可用于内网穿透的高性能的反向代理应用。<br/><a href=\"https://github.com/fatedier/frp\" target=\"_blank\">Github 项目地址</a>"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:43
|
||||
msgid "General Options"
|
||||
msgstr "常规选项"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:70
|
||||
msgid "Info"
|
||||
msgstr "信息"
|
||||
|
||||
#: luasrc/model/cbi/frps/server.lua:31
|
||||
msgid "KCP bind port"
|
||||
msgstr "KCP绑定端口"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:62
|
||||
msgid "Log file"
|
||||
msgstr "日志文件"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:66
|
||||
msgid "Log level"
|
||||
msgstr "日志等级"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:48
|
||||
msgid "Log max days"
|
||||
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
|
||||
msgid "Max pool count"
|
||||
msgstr "最大连接数"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:89
|
||||
msgid "Max ports per-client"
|
||||
msgstr "单客户端最大端口映射数"
|
||||
|
||||
#: luasrc/view/frps/status_header.htm:26
|
||||
msgid "Not Running"
|
||||
msgstr "服务未运行"
|
||||
|
||||
#: luasrc/model/cbi/frps/server.lua:40
|
||||
msgid "Optional: Note: http port and https port can be same with bind_port"
|
||||
msgstr "(可选)提示:http/https端口可以和绑定端口设定为一致"
|
||||
|
||||
#: luasrc/model/cbi/frps/server.lua:36
|
||||
msgid ""
|
||||
"Optional: if you want to support virtual host, you must set the http port "
|
||||
"for listening"
|
||||
msgstr "(可选)如果您希望支持虚拟主机,则必须设定http端口"
|
||||
|
||||
#: luasrc/model/cbi/frps/server.lua:28
|
||||
msgid "Optional: udp port to help make udp hole to penetrate nat"
|
||||
msgstr "(可选)设定UDP端口以帮助UDP协议穿透NAT"
|
||||
|
||||
#: luasrc/model/cbi/frps/server.lua:32
|
||||
msgid ""
|
||||
"Optional: udp port used for kcp protocol, it can be same with 'bind port'; "
|
||||
"if not set, kcp is disabled in frps"
|
||||
msgstr "(可选)UDP端口用于KCP协议,可与绑定端口设定为一致;留空以禁用KCP"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:53
|
||||
msgid "Run daemon as user"
|
||||
msgstr "以用户身份运行"
|
||||
|
||||
#: luasrc/controller/frps.lua:22
|
||||
msgid "Server"
|
||||
msgstr "服务端"
|
||||
|
||||
#: luasrc/controller/frps.lua:19
|
||||
msgid "Settings"
|
||||
msgstr "设置"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:95
|
||||
msgid "Subdomain host"
|
||||
msgstr "子域名"
|
||||
|
||||
#: luasrc/model/cbi/frps/server.lua:21
|
||||
msgid "TCP mux"
|
||||
msgstr "TCP 复用"
|
||||
|
||||
#: luasrc/model/cbi/frps/server.lua:27
|
||||
msgid "Enforce frps only accept TLS connection"
|
||||
msgstr "强制frps只接受TLS连接"
|
||||
|
||||
#: luasrc/model/cbi/frps/server.lua:28
|
||||
msgid "Requirements: frpc v0.25.0+, frps v0.32.0+"
|
||||
msgstr "要求:frpc版本0.25.0+, frps版本0.32.0+"
|
||||
|
||||
#: luasrc/model/cbi/frps/server.lua:18
|
||||
msgid "Token"
|
||||
msgstr "令牌"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:68
|
||||
msgid "Trace"
|
||||
msgstr "追踪"
|
||||
|
||||
#: luasrc/model/cbi/frps/server.lua:27
|
||||
msgid "UDP bind port"
|
||||
msgstr "UDP绑定端口"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:71
|
||||
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 "警告"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:45
|
||||
msgid "Error"
|
||||
msgstr "错误"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:99
|
||||
msgid "dashboard addr's default value is same with bind_addr"
|
||||
msgstr "面板地址默认和绑定地址一致"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:102
|
||||
msgid "dashboard is available only if dashboard_port is set"
|
||||
msgstr "仅在设定面板绑定端口后才可使用面板功能"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:105
|
||||
msgid ""
|
||||
"dashboard user and passwd for basic auth protect, if not set, both default "
|
||||
"value is admin"
|
||||
msgstr "面板用户名/密码用于基本安全认证;若留空,则用户名/密码均为admin"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:96
|
||||
msgid ""
|
||||
"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"
|
||||
msgstr "如果subdomain_host不为空,可以在frpc配置文件中设置类型为http(s)的subdomain;subdomain为test,路由将使用test.frps.com"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:90
|
||||
msgid ""
|
||||
"max ports can be used for each client, default value is 0 means no limit"
|
||||
msgstr "每个客户端最多可映射端口数,留空则默认为0(不限制)"
|
||||
|
||||
#: luasrc/model/cbi/frps/common.lua:86
|
||||
msgid ""
|
||||
"pool_count in each proxy will change to max_pool_count if they exceed the "
|
||||
"maximum value"
|
||||
msgstr "代理连接数(pool_count)超过最大值时将变更为最大连接数(max_pool_count)"
|
||||
|
||||
#: luasrc/model/cbi/frps/server.lua:35
|
||||
msgid "vhost http port"
|
||||
msgstr "虚拟主机http绑定端口"
|
||||
|
||||
#: luasrc/model/cbi/frps/server.lua:39
|
||||
msgid "vhost https port"
|
||||
msgstr "虚拟主机https绑定端口"
|
||||
|
||||
#: luasrc/model/cbi/frps/server.lua:50
|
||||
msgid "Extra Settings"
|
||||
msgstr "额外设置"
|
||||
|
||||
#: 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!)"
|
||||
msgstr "额外设置列表将会被添加到config文件中。 格式:option=value,如:<code>detailed_errors_to_client=false</code>.(不含空格!)"
|
||||
|
||||
#: luasrc/view/frps/frps_status.htm:7
|
||||
msgid "Open Frps page"
|
||||
msgstr "打开 Frps 管理面板"
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
zh-cn
|
||||
@@ -0,0 +1,8 @@
|
||||
config frps 'main'
|
||||
option enabled '0'
|
||||
option server 'frps'
|
||||
option dashboard_addr '0.0.0.0'
|
||||
option client_file '/usr/bin/frps'
|
||||
option bind_port '7000'
|
||||
option dashboard_port '7500'
|
||||
option tcp_mux 'true'
|
||||
Executable
+197
@@ -0,0 +1,197 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
# Copyright 2020 lwz322 <lwz322@qq.com>
|
||||
# Licensed to the public under the MIT License.
|
||||
#
|
||||
|
||||
START=99
|
||||
USE_PROCD=1
|
||||
|
||||
NAME="frps"
|
||||
CONFIG_FOLDER="/var/etc/$NAME"
|
||||
|
||||
_log() {
|
||||
local level="$1" ; shift
|
||||
local msg="$@"
|
||||
logger -p "daemon.$level" -t "$NAME" "$msg"
|
||||
|
||||
echo "[$level] $msg" >&2
|
||||
}
|
||||
|
||||
_info() {
|
||||
_log "info" $@
|
||||
}
|
||||
|
||||
_err() {
|
||||
_log "err" $@
|
||||
}
|
||||
|
||||
append_options() {
|
||||
local file="$1" ; shift
|
||||
local o v
|
||||
for o in "$@" ; do
|
||||
v="$(eval echo "\$$o")"
|
||||
if [ -n "$v" ] ; then
|
||||
# add brackets when ipv6 address
|
||||
if ( echo "$o" | grep -qE 'addr|ip' ) &&
|
||||
( echo "$v" | grep -q ':' ) ; then
|
||||
v="[$v]"
|
||||
fi
|
||||
|
||||
echo "${o} = $v" >>"$file"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
append_setting() {
|
||||
local file="$1" ; shift
|
||||
local s="$1"
|
||||
if [ -n "$s" ] ; then
|
||||
echo "$s" >>"$file"
|
||||
fi
|
||||
}
|
||||
|
||||
frps_scetion_validate() {
|
||||
uci_validate_section "$NAME" "frps" "$1" \
|
||||
'enabled:bool:0' \
|
||||
'client_file:file:/usr/bin/frps' \
|
||||
'run_user:string' \
|
||||
'enable_logging:bool:0' \
|
||||
'log_file:string:/var/log/frps.log' \
|
||||
'log_level:or("trace", "debug", "info", "warn", "error"):warn' \
|
||||
'log_max_days:uinteger:3' \
|
||||
'disable_log_color:or("true", "false")' \
|
||||
'max_pool_count:uinteger' \
|
||||
'max_ports_per_client:uinteger:0' \
|
||||
'subdomain_host:host' \
|
||||
'dashboard_addr:host' \
|
||||
'dashboard_port:port' \
|
||||
'dashboard_user:string' \
|
||||
'dashboard_pwd:string' \
|
||||
'bind_port:port' \
|
||||
'token:string' \
|
||||
'tcp_mux:or("true", "false"):true' \
|
||||
'tls_only:or("true", "false"):false' \
|
||||
'bind_udp_port:port' \
|
||||
'kcp_bind_port:port' \
|
||||
'vhost_http_port:port' \
|
||||
'vhost_https_port:port'
|
||||
}
|
||||
|
||||
client_file_validate() {
|
||||
local file="$1"
|
||||
|
||||
test -f "$file" || return 1
|
||||
test -x "$file" || chmod 755 "$file"
|
||||
|
||||
eval "$file" -h | grep -q "$NAME"
|
||||
return $?
|
||||
}
|
||||
|
||||
add_rule_extra_option() {
|
||||
append_setting "$2" "$1"
|
||||
}
|
||||
|
||||
create_config_file() {
|
||||
local config_file="$1"
|
||||
local tmp_file="$(mktemp /tmp/frps-XXXXXX)"
|
||||
|
||||
echo "[common]" > "$tmp_file"
|
||||
|
||||
append_options "$tmp_file" \
|
||||
"bind_port" "token" "tcp_mux" "tls_only" "bind_udp_port" "kcp_bind_port" "vhost_http_port" "vhost_https_port"
|
||||
|
||||
|
||||
if [ "x$enable_logging" = "x1" ] ; then
|
||||
if [ -z "$log_file" ]; then
|
||||
log_file="/var/log/frps.log"
|
||||
fi
|
||||
|
||||
append_options "$tmp_file" \
|
||||
"log_file" "log_level" "log_max_days" "disable_log_color"
|
||||
|
||||
if [ -f "$log_file" ] ; then
|
||||
echo > "$log_file"
|
||||
else
|
||||
local log_folder="$(dirname "$log_file")"
|
||||
|
||||
if [ ! -d "$log_folder" ] ; then
|
||||
mkdir -p "$log_folder"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$run_user" ] && ( user_exists "$run_user" ) ; then
|
||||
chmod 644 "$log_file"
|
||||
chown "$run_user" "$log_file"
|
||||
else
|
||||
run_user=""
|
||||
fi
|
||||
fi
|
||||
|
||||
append_options "$tmp_file" \
|
||||
"max_pool_count" "max_ports_per_client" "subdomain_host" "dashboard_addr" "dashboard_port" "dashboard_user" "dashboard_pwd"
|
||||
|
||||
extra_setting=$(uci get frps.main.extra_setting 2>/dev/null)
|
||||
if [ -n "$extra_setting" ] ; then
|
||||
for o in $extra_setting ;do
|
||||
echo "$o" >> "$tmp_file"
|
||||
done
|
||||
fi
|
||||
|
||||
sed '/^$/d' "$tmp_file" >"$config_file"
|
||||
|
||||
if [ "$?" = "0" ] ; then
|
||||
rm -f "$tmp_file"
|
||||
fi
|
||||
}
|
||||
|
||||
start_instance() {
|
||||
local section="$1"
|
||||
|
||||
if ! frps_scetion_validate "$section" ; then
|
||||
_err "Config validate failed."
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ "x$enabled" != "x1" ] ; then
|
||||
_info "Instance \"$section\" disabled."
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -z "$client_file" ] || ( ! client_file_validate "$client_file" ) ; then
|
||||
_err "Client file not valid."
|
||||
return 1
|
||||
fi
|
||||
|
||||
test -d "$CONFIG_FOLDER" || mkdir -p "$CONFIG_FOLDER"
|
||||
|
||||
local config_file="$CONFIG_FOLDER/frps.$section.ini"
|
||||
|
||||
create_config_file "$config_file"
|
||||
|
||||
if [ ! -f "$config_file" ] ; then
|
||||
_err "Could not create config file: \"$config_file\""
|
||||
return 1
|
||||
fi
|
||||
|
||||
procd_open_instance "$NAME.$section"
|
||||
procd_set_param command "$client_file"
|
||||
procd_append_param command -c "$config_file"
|
||||
procd_set_param respawn
|
||||
procd_set_param file "$config_file"
|
||||
|
||||
if [ -n "$run_user" ] ; then
|
||||
procd_set_param user "$run_user"
|
||||
fi
|
||||
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "$NAME"
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load "$NAME"
|
||||
config_foreach start_instance "frps"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
[ ! -f "/usr/share/ucitrack/luci-app-frps.json" ] && {
|
||||
cat > /usr/share/ucitrack/luci-app-frps.json << EEOF
|
||||
{
|
||||
"config": "frps",
|
||||
"init": "frps"
|
||||
}
|
||||
EEOF
|
||||
}
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@frps[-1]
|
||||
add ucitrack frps
|
||||
set ucitrack.@frps[-1].init=frps
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -rf /tmp/luci-indexcache /tmp/luci-modulecache
|
||||
exit 0
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-frps": {
|
||||
"description": "Grant UCI access for luci-app-frps",
|
||||
"read": {
|
||||
"uci": [ "frps" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "frps" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user