update 2024-12-30 09:28:05

This commit is contained in:
kenzok8 2024-12-30 09:28:05 +08:00
parent 3177e4f2af
commit c6f0c1a97b
12 changed files with 3 additions and 753 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=frp
PKG_VERSION:=0.61.1
PKG_VERSION:=0.51.3
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz

View File

@ -1,38 +0,0 @@
#
# 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.3
PKG_RELEASE:=1
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE
PKG_MAINTAINER:=lwz322 <lwz322@qq.com>
LUCI_TITLE:=LuCI support for Frps
LUCI_PKGARCH:=all
define Package/$(PKG_NAME)/conffiles
/etc/config/frps
endef
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/luci_frps" >/dev/null 2>&1
ln -sf "../init.d/luci_frps" \
"$${IPKG_INSTROOT}/etc/rc.d/S99frps" >/dev/null 2>&1
exit 0
endef
# call BuildPackage - OpenWrt buildroot signature

View File

@ -1,63 +0,0 @@
-- Copyright 2020 lwz322 <lwz322@qq.com>
-- 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"
-- 查看配置文件所需
local e=require"nixio.fs"
local t=require"luci.sys"
local a=require"luci.template"
local t=require"luci.i18n"
module("luci.controller.frps", package.seeall)
function index()
if not nixio.fs.access("/etc/config/frps") then
return
end
entry({"admin", "services", "frps"}, firstchild(), _("Frps")).dependent = false
entry({"admin", "services", "frps", "common"}, cbi("frps/common"), _("设置"), 1)
entry({"admin", "services", "frps", "status"}, call("action_status"))
entry({"admin", "services", "frps", "configuration"}, call("view_conf"), _("查看配置"), 3).leaf = true
entry({"admin", "services", "frps", "get_log"}, call("get_log")).leaf = true
entry({"admin", "services", "frps", "clear_log"}, call("clear_log")).leaf = true
entry({"admin", "services", "frps", "log"}, cbi("frps/log"), _("查看日志"), 6).leaf = true
end
function action_status()
local running = false
local client = uci:get("frps", "main", "client_file")
if client and client ~= "" then
local file_name = client:match(".*/([^/]+)$") or ""
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
function view_conf()
local e=e.readfile("/var/etc/frps/frps.main.toml")or""
a.render("frps/file_viewer",
{title=t.translate("Frps - 查看配置文件"),content=e})
end
function get_log()
luci.http.write(luci.sys.exec("cat /tmp/frps_log_link.txt"))
end
function clear_log()
luci.sys.call("true > /tmp/frps_log_link.txt")
end

View File

@ -1,209 +0,0 @@
-- Copyright 2020 lwz322 <lwz322@qq.com> #modify by superzjg@gmail.com 20240811
-- 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 server_table = { }
local function frps_version()
local file = uci:get("frps", "main", "client_file")
if not file or file == "" or not fs.stat(file) then
return "<em style=\"color: red;\">%s</em>" % translate("可执行文件无效")
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("未能获取到版本信息")
end
if version < "0.52.0" then
return "<em style=\"color: red;\">%s</em>" % translatef("升级至 0.52.0 或以上才支持toml配置文件当前版本%s", version)
end
return translatef("版本: %s", version)
end
m = Map("frps", "%s - %s" % { translate("Frps"), translate("通用设置") },
"<p>%s</p><p>%s</p>" % {
translate("Frp 是一个可用于内网穿透的高性能的反向代理应用。"),
translatef("获取更多信息,请访问:%s",
"<a href=\"https://github.com/fatedier/frp\" target=\"_blank\">https://github.com/fatedier/frp</a>;官方文档:<a href=\"https://gofrp.org/zh-cn/\" target=\"_blank\">gofrp.org</a>")
})
m:append(Template("frps/status_header"))
s = m:section(NamedSection, "main", "frps")
s.addremove = false
s.anonymous = true
s:tab("general", translate("常规选项"))
s:tab("basic", translate("基础选项"))
s:tab("advanced", translate("高级选项"))
s:tab("dashboard", translate("管理面板选项"))
o = s:taboption("general", Flag, "enabled", translate("启用"))
o = s:taboption("general", Value, "client_file", translate("可执行文件路径"), frps_version())
o.datatype = "file"
o.rmempty = false
o.default = "/usr/bin/frps"
o = s:taboption("general", ListValue, "run_user", translate("以用户身份运行"))
o:value("", translate("-- 默认 --"))
local user
for user in util.execi("cat /etc/passwd | cut -d':' -f1") do
o:value(user)
end
o = s:taboption("general", ListValue, "set_firewall", translate("防火墙通信规则"), translate("检测:启动服务,无规则将建立,停止服务时不删除<br/>强制:启动时删除并重建,停止时删除"))
o:value("no", translate("不操作"))
o:value("check", translate("检测"))
o:value("force", translate("强制"))
o.default = "no"
o = s:taboption("general", Value, "tcp_ports", translate("防火墙通信规则-TCP端口"), translate("多端口号用空格隔开,下同"))
o:depends("set_firewall", "check")
o:depends("set_firewall", "force")
o = s:taboption("general", Value, "udp_ports", translate("防火墙通信规则-UDP端口"))
o:depends("set_firewall", "check")
o:depends("set_firewall", "force")
o = s:taboption("general", Flag, "enable_logging", translate("启用日志"),
translate("Frp 运行日志设置。不含 luci-app 日志(此部分在“系统日志”查看)"))
o = s:taboption("general", Flag, "std_redirect", translate("重定向标准输出"),
translate("Frp的标准输出、标准错误重定向到日志文件"))
o:depends("enable_logging", "1")
o = s:taboption("general", Value, "log__to", translate("日志文件"),translate("填写文件路径,留空相当于填入 console日志打印在标准输出中"))
o:depends("enable_logging", "1")
o.default = "/var/log/frps.log"
o = s:taboption("general", ListValue, "log__level", translate("日志等级"),translate("留空默认info"))
o:depends("enable_logging", "1")
o:value("", translate("(空)"))
o:value("trace", translate("追踪"))
o:value("debug", translate("调试"))
o:value("info", translate("信息"))
o:value("warn", translate("警告"))
o:value("error", translate("错误"))
o = s:taboption("general", Value, "log__maxDays", translate("日志保存天数"),translate("留空默认 3 天不含当天会按日期命名文件1天1个"))
o:depends("enable_logging", "1")
o.datatype = "uinteger"
o.placeholder = '3'
o = s:taboption("general", Flag, "log__disablePrintColor", translate("禁用日志颜色"),
translate("当日志文件为 console 时禁用日志颜色,默认不禁用"))
o:depends("enable_logging", "1")
o.enabled= "true"
o.disabled = ""
o = s:taboption("basic", Value, "bindAddr", translate("绑定地址"), translate("留空即所有地址含IPv6"))
o.placeholder = "0.0.0.0"
o = s:taboption("basic", Value, "bindPort", translate("绑定端口"))
o.datatype = "integer"
o.placeholder = "7000"
o = s:taboption("basic", ListValue, "auth__method", translate("鉴权方式"),
translate("留空默认 token若用 oidc 请使用“高级选项”中的 “额外选项” 添加参数"))
o:value("", translate("(空)"))
o:value("token")
o:value("oidc")
o = s:taboption("basic", Value, "auth__token", translate("鉴权令牌"))
o.password = true
o:depends("auth__method", "")
o:depends("auth__method", "token")
o = s:taboption("basic", Flag, "transport__tcpMux", translate("关闭 TCP 复用"),
translate("Frps 默认开启 tcpMux。提示frpc 和 frps 要作相同设置"))
o.enabled = "false"
o.disabled = ""
o = s:taboption("basic", Value, "transport__tcpMuxKeepaliveInterval", translate("tcpMux心跳检查间隔秒数"))
o:depends("transport__tcpMux", "")
o.datatype = "uinteger"
o.placeholder = "30"
o = s:taboption("basic", Value, "kcpBindPort", translate("KCP绑定端口"),
translatef("UDP端口用于kcp协议建议不要与QUIC端口冲突留空以禁用kcp"))
o.datatype = "port"
o = s:taboption("basic", Value, "quicBindPort", translate("QUIC绑定端口"),
translatef("UDP端口用于quic协议建议不要与KCP端口冲突留空以禁用quic"))
o.datatype = "port"
o = s:taboption("basic", Value, "vhostHTTPPort", translate("虚拟主机HTTP端口"),
translatef("如果希望支持虚拟主机,则必须设定 http 或 https 端口"))
o.datatype = "port"
o = s:taboption("basic", Value, "vhostHTTPSPort", translate("虚拟主机HTTPS端口"),
translatef("注意frpc 默认禁用了TLS第一个自定义字节可能影响端口号复用建议查阅官方文档"))
o.datatype = "port"
o = s:taboption("advanced", Value, "transport__maxPoolCount", translate("最大连接池大小"),
translate("每个代理的连接池大小 poolCount 不会超过此值"))
o.datatype = "uinteger"
o.placeholder = '5'
o = s:taboption("advanced", Value, "maxPortsPerClient", translate("单客户端最大代理数"),
translate("限制每个客户端最多可映射端口数留空则默认为0不限制"))
o.datatype = "uinteger"
o.placeholder = '0'
o = s:taboption("advanced", Value, "allowPorts", translate("允许的端口"),
translate("允许代理绑定的服务端端口默认留空不限制。注意用英文逗号和中横线例如简写为3000-4000,5000,6000-50000 即可,后台会转换格式"))
o = s:taboption("advanced", Value, "subDomainHost", translate("子域名后缀"),
translatef("如果subDomainHost不为空例如frps.com可在frpc中对类型为http(s)的代理设置subdomain若设为test路由将使用test.frps.com"))
o.datatype = "host"
o = s:taboption("advanced", Flag, "transport__tls__force", translate("强制frps只接受TLS连接"))
o.enabled = "true"
o.disabled = ""
o = s:taboption("advanced", Value, "transport__tls__certFile", translate("TLS服务端证书文件路径"))
o.datatype = "file"
o = s:taboption("advanced", Value, "transport__tls__keyFile", translate("TLS服务端密钥文件路径"))
o.datatype = "file"
o = s:taboption("advanced", Value, "transport__tls__trustedCaFile", translate("TLS CA证书路径"))
o.datatype = "file"
o = s:taboption("advanced", Value, "transport__heartbeatTimeout", translate("心跳超时"),
translate("与客户端心跳连接的超时时间(秒),负数禁用,默认-1因frp默认开启TCP复用tcpmux进行心跳检测"))
o.datatype = "integer"
o.placeholder = "-1"
o = s:taboption("advanced", Value, "proxyBindAddr", translate("代理监听地址"),
translate("使代理监听在不同的地址(新手慎用)。留空,即默认在绑定地址监听"))
o = s:taboption("advanced", DynamicList, "extra_setting", translate("额外选项"),
translatef("点击添加列表一行一条写入frp的配置文件的通用部分末尾格式错误可能导致无法启动服务"))
o.placeholder = "option = value"
o = s:taboption("dashboard", Value, "webServer__addr", translate("面板地址"), translatef("默认本机访问;要远程访问按需设置"))
o.datatype = "host"
o.placeholder = "127.0.0.1"
o = s:taboption("dashboard", Value, "webServer__port", translate("面板端口"))
o.datatype = "port"
o = s:taboption("dashboard", Value, "webServer__user", translate("登录用户名"))
o = s:taboption("dashboard", Value, "webServer__password", translate("登录密码"))
o.password = true
o = s:taboption("dashboard", Value, "webServer__tls__certFile", translate("TLS证书文件路径"), translate("证书和密钥都配置表示面板开启TLS都留空即不开启"))
o.datatype = "file"
o = s:taboption("dashboard", Value, "webServer__tls__keyFile", translate("TLS密钥文件路径"))
o.datatype = "file"
return m

View File

@ -1,5 +0,0 @@
m = Map("frps", "%s - %s" % { translate("Frps"), translate("查看日志文件") })
m:append(Template("frps/frps_log"))
return m

View File

@ -1,8 +0,0 @@
<%+header%>
<h2 name="title"><%=title%></h2>
文件路径:/var/etc/frps/frps.main.toml启用服务后才能生成
<div id="content_fileviewer">
<textarea style="width: 100%" readonly="readonly" wrap="off" rows="<%=content:cmatch("\n")+1%>" id="content_id"><%=content:pcdata()%></textarea>
</div>
<%+footer%>

View File

@ -1,36 +0,0 @@
<script type="text/javascript">
//<![CDATA[
function clear_log(btn) {
XHR.get('<%=url([[admin]], [[services]], [[frps]], [[clear_log]])%>', null,
function(x, data) {
if(x && x.status == 200) {
var log_textarea = document.getElementById('log_textarea');
log_textarea.innerHTML = "";
log_textarea.scrollTop = log_textarea.scrollHeight;
}
location.reload();
}
);
}
var scrolled = false;
XHR.poll(2, '<%=url([[admin]], [[services]], [[frps]], [[get_log]])%>', null,
function(x, data) {
if(x && x.status == 200) {
var log_textarea = document.getElementById('log_textarea');
var str = x.responseText;
var logs = str.replace(//g, "🔧");
log_textarea.innerHTML = logs;
if (!scrolled) {
log_textarea.scrollTop = log_textarea.scrollHeight;
scrolled = true;
}
}
}
);
//]]>
</script>
<fieldset class="cbi-section" id="_log_fieldset">
<input class="cbi-button cbi-input-remove" type="button" onclick="clear_log()" value="<%:清空日志%>" style="margin-left: 10px; margin-top: 10px;">
&nbsp;(读取软链接:/tmp/frps_log_link.txt
<textarea id="log_textarea" class="cbi-input-textarea" style="width: calc(100% - 20px); height: 500px; margin: 10px;" data-update="change" rows="5" wrap="off" readonly="readonly"></textarea>
</fieldset>

View File

@ -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
? '<b><font color=green><%:Frps 正在运行%></font></b>'
: '<b><font color=red><%:Frps 未运行%></font></b>';
}
);
//]]></script>

View File

@ -1,4 +0,0 @@
config frps 'main'
option enabled '0'
option client_file '/usr/bin/frps'
option bindPort '7000'

View File

@ -1,347 +0,0 @@
#!/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" $@
}
# 因Uci的option名不能带 . 号,故用 __ 替代在调用此函数时frp参数名称分3类
# 1.Toml字符串类直接使用并加双引号输出
# 2.Toml布尔和整数使用时名称请附加 ..INT 后缀,在此处理后,并原样输出
# 3.Toml数组使用时请附加 ..ARR 后缀,网页端可 不加引号使用逗号或空格分隔 的简写方式,处理后,再加方括号输出
# 4.uci值存在单独的 * 号时如frpc参数allowUsers可能导致for取值异常要处理
append_options() {
local file="$1" ; shift
local o v f
for o in "$@" ; do
f=""
if [ -n "$(echo $o | grep "..INT")" ];then
f=1
o=${o//..INT/}
fi
if [ -n "$(echo $o | grep "..ARR")" ];then
f=2
o=${o//..ARR/}
fi
eval v=\$${o//./__}
if [ -n "$v" ] ; then
[ "$f" == "" ] && echo "$o = \"$v\"" >>"$file"
[ "$f" == "1" ] && echo "$o = $v" >>"$file"
if [ "$f" == "2" ];then
local T M
M=""
if [ "$o" == "allowPorts" ];then
# 对allowPorts特殊处理标准写法和简写法
if [ -n "$(echo "$v" | grep "{" | grep "}")" ];then
echo "$o = [ $v ]" >>"$file"
else
v=${v//,/ }
for T in $v ; do
if [ -z "$(echo "$T" | grep "\-")" ];then
T="{ single = $T }"
else
[ "${T%-*}" -ge "${T#*-}" ] && continue
T="{ start = ${T%-*}, end = ${T#*-} }"
fi
[ -n "$M" ] && M="$M, "
M=$M$T
done
echo "$o = [ $M ]" >>"$file"
fi
else
# 逗号替换为空格
v=${v//,/ }
# 查找单个的 * ,替换为 "*" 。
if [ -n "$(echo "$v" | grep "^\* \| \* \| \*$")" ];then
v="${v//\*/\"*\"}"
fi
[ "$v" == "*" ] && v=\"*\"
for T in $v ; do
# 忽略单个的 ' 或 " 符。
if [ "${T:0:1}" == "\"" -o "${T:0:1}" == "'" ] && [ "${#T}" == "1" ];then
continue
fi
# 除首尾同是 ' 或同是 " 外,删除所有 ' 或 " ,并补全首尾的 " 。
# if [ "${T:0:1}" == "\"" -a "${T: -1}" == "\"" ] || [ "${T:0:1}" == "'" -a "${T: -1}" == "'" ];then
if [ "${T:0:1}" == "\"" -a "$(echo -n "$T" | tail -c 1)" == "\"" ] || [ "${T:0:1}" == "'" -a "$(echo -n "$T" | tail -c 1)" == "'" ];then
true
else
T=${T//\'/}
T=\"${T//\"/}\"
fi
# 用逗号+空格组合
[ -n "$M" ] && M="$M, "
M=$M$T
done
echo "$o = [$M]" >>"$file"
fi
fi
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' \
'set_firewall:string' \
'tcp_ports:string' \
'udp_ports:string' \
'enable_logging:bool:0' \
'std_redirect:bool:0' \
'log__to:string' \
'log__level:or("trace", "debug", "info", "warn", "error")' \
'log__maxDays:uinteger' \
'log__disablePrintColor:or("true", "false")' \
'bindAddr:string' \
'bindPort:integer' \
'auth__method:or("token", "oidc")' \
'auth__token:string' \
'transport__tcpMux:or("true", "false")' \
'transport__tcpMuxKeepaliveInterval:uinteger' \
'kcpBindPort:port' \
'quicBindPort:port' \
'vhostHTTPPort:port' \
'vhostHTTPSPort:port' \
'transport__maxPoolCount:uinteger' \
'maxPortsPerClient:uinteger' \
'allowPorts:string' \
'subDomainHost:host' \
'transport__tls__force:or("true", "false")' \
'transport__tls__certFile:file' \
'transport__tls__keyFile:file' \
'transport__tls__trustedCaFile:file' \
'transport__heartbeatTimeout:integer' \
'proxyBindAddr:string' \
'extra_setting:list(string)' \
'webServer__addr:host' \
'webServer__port:port' \
'webServer__user:string' \
'webServer__password:string' \
'webServer__tls__certFile:file' \
'webServer__tls__keyFile:file'
}
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 "# 文件生成时间:$(date +%Y-%m-%d_%H:%M:%S)" > "$tmp_file"
append_options "$tmp_file" \
"bindAddr" "bindPort..INT" "proxyBindAddr" "auth.method" "auth.token" "kcpBindPort..INT" "quicBindPort..INT" \
"vhostHTTPPort..INT" "vhostHTTPSPort..INT" "transport.tcpMux..INT" "transport.tcpMuxKeepaliveInterval..INT"
if [ "x$enable_logging" = "x1" ] ; then
append_options "$tmp_file" \
"log.to" "log.level" "log.maxDays..INT" "log.disablePrintColor..INT"
fi
append_options "$tmp_file" \
"transport.maxPoolCount..INT" "maxPortsPerClient..INT" "transport.heartbeatTimeout..INT" "subDomainHost" "allowPorts..ARR" \
"transport.tls.force..INT" "transport.tls.certFile" "transport.tls.keyFile" "transport.tls.trustedCaFile" \
"webServer.addr" "webServer.port..INT" "webServer.user" "webServer.password" "webServer.tls.certFile" "webServer.tls.keyFile"
config_list_foreach "$section" "extra_setting" add_rule_extra_option "$tmp_file"
sed '/^$/d' "$tmp_file" >"$config_file"
if [ "$?" = "0" ] ; then
rm -f "$tmp_file"
fi
}
add_firewall() {
if [ "$set_firewall" != "no" ]; then
local mark1=0
local mark2=0
if [ -n "$tcp_ports" ]; then
mark1=1
[ "$set_firewall" == "check" ] && [ "$tcp_ports" == "$(uci -q get firewall.frps_t_auto.dest_port)" ] && mark1=0
if [ "$mark1" == "1" ]; then
uci -q delete firewall.frps_t_auto
uci set firewall.frps_t_auto=rule
uci set firewall.frps_t_auto.name="frps_t_auto"
uci set firewall.frps_t_auto.target="ACCEPT"
uci set firewall.frps_t_auto.src="wan"
uci set firewall.frps_t_auto.proto="tcp"
uci set firewall.frps_t_auto.dest_port="$tcp_ports"
uci set firewall.frps_t_auto.enabled="1"
fi
fi
if [ -n "$udp_ports" ]; then
mark2=1
[ "$set_firewall" == "check" ] && [ "$udp_ports" == "$(uci -q get firewall.frps_u_auto.dest_port)" ] && mark2=0
if [ "$mark2" == "1" ]; then
uci -q delete firewall.frps_u_auto
uci set firewall.frps_u_auto=rule
uci set firewall.frps_u_auto.name="frps_u_auto"
uci set firewall.frps_u_auto.target="ACCEPT"
uci set firewall.frps_u_auto.src="wan"
uci set firewall.frps_u_auto.proto="udp"
uci set firewall.frps_u_auto.dest_port="$udp_ports"
uci set firewall.frps_u_auto.enabled="1"
fi
fi
[ "$mark1" == "0" ] && [ "$mark2" == "0" ] && return 0
uci commit firewall
/etc/init.d/firewall reload >/dev/null 2>&1
fi
}
del_firewall() {
if [ "$set_firewall" == "force" ]; then
local A=$(uci -q show firewall.frps_t_auto)
local B=$(uci -q show firewall.frps_u_auto)
[ -n "$A" ] && uci -q delete firewall.frps_t_auto
[ -n "$B" ] && uci -q delete firewall.frps_u_auto
if [ -n "$A" ] || [ -n "$B" ]; then
uci commit firewall
/etc/init.d/firewall reload >/dev/null 2>&1
fi
fi
}
logfile_prepare() {
if [ "x$enable_logging" != "x1" ];then
rm -f /tmp/frps_log_link.txt
rm -f /tmp/frps_std_redirect.log
echo "未配置日志输出保存" > /tmp/frps_log_link.txt
return 1
fi
if [ "${std_redirect}" == "1" ];then
if [ -z "${log__to}" -o "${log__to}" == "console" ];then
log__to=/tmp/frps_std_redirect.log
true >"${log__to}"
else
mkdir -p "$(dirname "${log__to}")"
touch "${log__to}"
if [ "$?" != "0" ];then
log__to=/tmp/frps_std_redirect.log
echo "【$(date +%Y-%m-%d_%H:%M:%S)】--->警告:配置的日志文件路径似乎无效/只读!" > "${log__to}"
fi
fi
fi
if [ -n "${log__to}" -a "${log__to}" != "console" ];then
mkdir -p "$(dirname "${log__to}")"
touch "${log__to}"
fi
if [ -n "$run_user" ]; then
chmod 644 "$log__to"
chown "$run_user" "$log__to"
fi
# 创建log文件读取链接用于luci查看日志
ln -sf "${log__to}" /tmp/frps_log_link.txt
}
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."
del_firewall
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.toml"
create_config_file "$config_file"
if [ ! -f "$config_file" ] ; then
_err "Could not create config file: \"$config_file\""
return 1
fi
logfile_prepare
procd_open_instance "$NAME.$section"
if [ "${std_redirect}" == "1" ];then
procd_set_param command "/bin/sh"
procd_append_param command -c "exec $client_file -c $config_file >>\"${log__to}\" 2>&1"
else
procd_set_param command "$client_file"
procd_append_param command -c "$config_file"
fi
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
add_firewall
}
service_triggers() {
procd_add_reload_trigger "$NAME"
}
start_service() {
config_load "$NAME"
config_foreach start_instance "frps"
}
stop_service() {
# config_load "$NAME"
# config_get set_firewall main set_firewall
set_firewall=$(uci get frps.main.set_firewall 2>/dev/null)
del_firewall
}

View File

@ -1,11 +0,0 @@
#!/bin/sh
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

View File

@ -30,13 +30,13 @@ define Download/geosite
HASH:=aa65cee72dd6afbf9dd4c474b4ff28ceb063f6abf99249a084091adb4f282f09
endef
GEOSITE_IRAN_VER:=202412230035
GEOSITE_IRAN_VER:=202412300035
GEOSITE_IRAN_FILE:=iran.dat.$(GEOSITE_IRAN_VER)
define Download/geosite-ir
URL:=https://github.com/bootmortis/iran-hosted-domains/releases/download/$(GEOSITE_IRAN_VER)/
URL_FILE:=iran.dat
FILE:=$(GEOSITE_IRAN_FILE)
HASH:=fcf072abdad21399b442ff5474a60802efb264bfc8aa3f90048c343fd296dc89
HASH:=a2c0b714f8d30bfeabb8933b4a322a9cbe7b9fe1a8c3ee36b9afbcced0a4e19f
endef
define Package/v2ray-geodata/template